change printed info

This commit is contained in:
2025-05-10 17:47:35 +02:00
parent 7827b9c0cc
commit f791b7085c

View File

@@ -39,7 +39,7 @@ func (p RunCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) su
for _, metadata := range datastore { for _, metadata := range datastore {
metadataPath := filepath.Join(game.DatastorePath(), metadata.ID) metadataPath := filepath.Join(game.DatastorePath(), metadata.ID)
err := archiveIfChanged(metadata.Path, filepath.Join(metadataPath, "data.tar.gz"), filepath.Join(metadataPath, ".last_run")) err := archiveIfChanged(metadata.ID, metadata.Path, filepath.Join(metadataPath, "data.tar.gz"), filepath.Join(metadataPath, ".last_run"))
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "error: cannot process the data of %s: %s\n", metadata.ID, err) fmt.Fprintf(os.Stderr, "error: cannot process the data of %s: %s\n", metadata.ID, err)
return subcommands.ExitFailure return subcommands.ExitFailure
@@ -52,7 +52,7 @@ func (p RunCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) su
// archiveIfChanged will archive srcDir into destTarGz only if any file // archiveIfChanged will archive srcDir into destTarGz only if any file
// in srcDir has a modification time > the last run time stored in stateFile. // in srcDir has a modification time > the last run time stored in stateFile.
// After archiving, it updates stateFile to the current time. // After archiving, it updates stateFile to the current time.
func archiveIfChanged(srcDir, destTarGz, stateFile string) error { func archiveIfChanged(id, srcDir, destTarGz, stateFile string) error {
// 1) Load last run time // 1) Load last run time
var lastRun time.Time var lastRun time.Time
data, err := os.ReadFile(stateFile) data, err := os.ReadFile(stateFile)
@@ -83,7 +83,6 @@ func archiveIfChanged(srcDir, destTarGz, stateFile string) error {
} }
if !changed { if !changed {
fmt.Println("No changes detected; skipping archive.")
return nil return nil
} }
@@ -142,6 +141,7 @@ func archiveIfChanged(srcDir, destTarGz, stateFile string) error {
return fmt.Errorf("updating state file: %w", err) return fmt.Errorf("updating state file: %w", err)
} }
fmt.Printf("Archived %q to %q and updated state file.\n", srcDir, destTarGz) fmt.Println(id)
return nil return nil
} }