55 "os"
66 "path/filepath"
77 "strings"
8+ "time"
89
910 "github.com/JacksonTheMaster/StationeersServerUI/v5/src/logger"
1011)
@@ -38,7 +39,7 @@ func (m *BackupManager) RestoreBackup(index int) error {
3839 if targetGroup .BinFile != "" && strings .HasSuffix (targetGroup .BinFile , ".save" ) {
3940 // .save file case
4041 backupFile := targetGroup .BinFile
41- destFile := filepath .Join ("./saves/" + m .config .WorldName , filepath . Base ( backupFile ) )
42+ destFile := filepath .Join ("./saves/" + m .config .WorldName , m . config . WorldName + ".save" )
4243
4344 // Before restore, check if we have existing .save files in the root saves/WorldName dir
4445 saveDir := filepath .Join ("./saves/" , m .config .WorldName )
@@ -54,7 +55,8 @@ func (m *BackupManager) RestoreBackup(index int) error {
5455 if strings .HasSuffix (file .Name (), ".save" ) {
5556 existingFile := filepath .Join (saveDir , file .Name ())
5657 // Move existing .save file to SafeBackupDir with timestamp to avoid overwrites
57- savedPreviousHeadSaveFilePath := filepath .Join (m .config .SafeBackupDir , fmt .Sprintf ("%s_%s" , "_oldHeadSaveBackup" , file .Name ()))
58+ timestamp := time .Now ().Format ("2006-01-02_15-04-05" )
59+ savedPreviousHeadSaveFilePath := filepath .Join (m .config .SafeBackupDir , fmt .Sprintf ("%s_%s_%s" , "oldHeadSaveBackup" , timestamp , file .Name ()))
5860 if err := os .Rename (existingFile , savedPreviousHeadSaveFilePath ); err != nil {
5961 return fmt .Errorf ("failed to move existing HEAD .save file %s to %s: %w" , existingFile , savedPreviousHeadSaveFilePath , err )
6062 }
0 commit comments