Notify when prune completes
This commit is contained in:
@@ -427,8 +427,14 @@ func (s *Service) ForceUnlockRepository(ctx context.Context, repoID string) erro
|
||||
return s.restic.ForceUnlock(ctx, mounted.Repository)
|
||||
}
|
||||
|
||||
func (s *Service) execute(ctx context.Context, run model.Run) model.Run {
|
||||
func (s *Service) execute(ctx context.Context, run model.Run) (result model.Run) {
|
||||
ctx = restic.WithRunID(ctx, run.ID)
|
||||
maintenanceRepoName := ""
|
||||
defer func() {
|
||||
if result.TaskType == "prune" && (result.Status == "success" || result.Status == "warning" || result.Status == "failed") {
|
||||
go s.notify("Repository-Bereinigung", maintenanceRepoName, result)
|
||||
}
|
||||
}()
|
||||
if run.TaskType == "backup" {
|
||||
return s.executeBackup(ctx, run)
|
||||
}
|
||||
@@ -442,6 +448,7 @@ func (s *Service) execute(ctx context.Context, run model.Run) model.Run {
|
||||
if !ok {
|
||||
return failed(run, "validation", "repository no longer exists")
|
||||
}
|
||||
maintenanceRepoName = repo.Name
|
||||
live := run
|
||||
appendLiveLog(&live, strings.ToUpper(run.TaskType)+" wird vorbereitet")
|
||||
s.updateActive(live)
|
||||
@@ -817,7 +824,11 @@ func notificationMessage(name, repository string, run model.Run, now time.Time)
|
||||
if status == "" {
|
||||
status = run.Status
|
||||
}
|
||||
lines := []string{"📊 Backup-Zusammenfassung", ""}
|
||||
summaryTitle := map[string]string{"backup": "📊 Backup-Zusammenfassung", "rsync": "📊 Rsync-Zusammenfassung", "restore": "📊 Restore-Zusammenfassung", "prune": "🧹 Prune-Zusammenfassung", "check": "🔎 Prüfungs-Zusammenfassung"}[run.TaskType]
|
||||
if summaryTitle == "" {
|
||||
summaryTitle = "📊 URBM-Zusammenfassung"
|
||||
}
|
||||
lines := []string{summaryTitle, ""}
|
||||
if repository != "" {
|
||||
lines = append(lines, "📦 Repository: "+repository)
|
||||
}
|
||||
@@ -852,7 +863,7 @@ func notificationMessage(name, repository string, run model.Run, now time.Time)
|
||||
}
|
||||
}
|
||||
lines = append(lines, "", "🔐 Ziel: "+notificationTargetLabel(run.TaskType), statusIcon(run.Status)+" Status: "+status)
|
||||
if run.Message != "" && run.Message != "backup completed" && run.Message != "rsync completed" {
|
||||
if run.Message != "" && run.Message != run.TaskType+" completed" {
|
||||
lines = append(lines, "⚠️ Details: "+run.Message)
|
||||
}
|
||||
return strings.Join(lines, "\n")
|
||||
|
||||
Reference in New Issue
Block a user