diff --git a/cmd/purger/purger.go b/cmd/purger/purger.go index cc4fb43..5b6a5be 100644 --- a/cmd/purger/purger.go +++ b/cmd/purger/purger.go @@ -227,7 +227,13 @@ func pruneOldE(cmd *cobra.Command, args []string) error { if !daemon { break } - time.Sleep(time.Until(started.Add(24 * time.Hour))) + if time.Since(started) < time.Hour*24 { + remaining := time.Until(started.Add(24 * time.Hour)) + zlog.Info("Waiting before next run...", zap.Duration("remaining", remaining)) + time.Sleep(remaining) + } else { + zlog.Info("Next run will start immediately because it took more than 24 hours") + } } return nil } @@ -275,7 +281,6 @@ func runPruneOld(ctx context.Context, db *sqlx.DB, network string, maxAgeDays ui return fmt.Errorf("listing files: %w", err) } filesToPurge = append(filesToPurge, fmt.Sprintf("%s/substreams.partial.spkg.zst", path.Dir(relpath))) // go up one directory above and delete the substreams.partial.spkg.zst file - fmt.Println(filesToPurge[len(filesToPurge)-1]) if !force { fmt.Printf("%s:", cli.PurpleStyle.Render("List of files to purge")) diff --git a/go.mod b/go.mod index a4424d6..96872d1 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.23 require ( cloud.google.com/go/storage v1.27.0 + github.com/charmbracelet/huh v0.6.0 github.com/drone/envsubst v1.0.3 github.com/googleapis/gax-go/v2 v2.7.0 github.com/jmoiron/sqlx v1.4.0 @@ -28,7 +29,6 @@ require ( github.com/catppuccin/go v0.2.0 // indirect github.com/charmbracelet/bubbles v0.20.0 // indirect github.com/charmbracelet/bubbletea v1.1.0 // indirect - github.com/charmbracelet/huh v0.6.0 // indirect github.com/charmbracelet/lipgloss v1.0.0 // indirect github.com/charmbracelet/x/ansi v0.4.2 // indirect github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect