Add pause resume and abort controls

This commit is contained in:
Mikei386
2026-06-14 22:34:22 +02:00
parent 82d00bd116
commit 656d569b27
13 changed files with 228 additions and 11 deletions
+22
View File
@@ -168,6 +168,27 @@ func (s *Service) EnqueueRestore(task model.RestoreTask) (model.Run, error) {
func (s *Service) Cancel(runID string) bool { return s.queue.Cancel(runID) }
func (s *Service) ClearRunHistory() int { return s.queue.ClearHistory() }
func (s *Service) Pause(runID string) error {
if err := s.restic.Pause(runID); err != nil {
return fmt.Errorf("pause: %w", err)
}
if !s.queue.SetPaused(runID, true) {
_ = s.restic.Resume(runID)
return errors.New("pause: run is not currently running")
}
return nil
}
func (s *Service) Resume(runID string) error {
if err := s.restic.Resume(runID); err != nil {
return fmt.Errorf("resume: %w", err)
}
if !s.queue.SetPaused(runID, false) {
return errors.New("resume: run is not currently paused")
}
return nil
}
func (s *Service) Snapshots(ctx context.Context, repoID string) ([]model.Snapshot, error) {
repo, ok := s.repository(repoID)
if !ok {
@@ -212,6 +233,7 @@ func (s *Service) TestRepository(ctx context.Context, repoID string, initialize
}
func (s *Service) execute(ctx context.Context, run model.Run) model.Run {
ctx = restic.WithRunID(ctx, run.ID)
if run.TaskType == "backup" {
return s.executeBackup(ctx, run)
}