Skip to content

Commit 58fa17c

Browse files
committed
add: more user friendly info and warning
1 parent b192ee9 commit 58fa17c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/cmd/backup.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ func Backup() {
1818
backupVersion := backupSection.Key("version").MustString("")
1919
curBackupStatus := backupstatus.Get(prefsPath, backupFolder, backupVersion)
2020
if curBackupStatus != backupstatus.EMPTY {
21-
utils.PrintWarning("There is available backup, clear current backup first!")
21+
utils.PrintInfo("There is available backup, clear current backup:")
2222
ClearBackup()
23-
backupSection.Key("version").SetValue("")
24-
cfg.Write()
2523
}
2624

2725
utils.PrintBold("Backing up app files:")
@@ -92,7 +90,8 @@ func ClearBackup() {
9290
curSpotifystatus := spotifystatus.Get(spotifyPath)
9391

9492
if curSpotifystatus != spotifystatus.STOCK && !quiet {
95-
if !utils.ReadAnswer("Before clearing backup, make sure you have restored or re-installed Spotify to original state. Continue? [y/N]: ", false) {
93+
utils.PrintWarning("Before clearing backup, please restore or re-install Spotify to stock state.")
94+
if !utils.ReadAnswer("Continue clearing anyway? [y/N]: ", false) {
9695
os.Exit(1)
9796
}
9897
}
@@ -121,16 +120,21 @@ func ClearBackup() {
121120
func Restore() {
122121
backupVersion := backupSection.Key("version").MustString("")
123122
curBackupStatus := backupstatus.Get(prefsPath, backupFolder, backupVersion)
123+
curSpotifystatus := spotifystatus.Get(spotifyPath)
124124

125125
if curBackupStatus == backupstatus.EMPTY {
126126
utils.PrintError(`You haven't backed up.`)
127+
if curSpotifystatus != spotifystatus.STOCK {
128+
utils.PrintWarning(`But Spotify cannot be backed up at this state. Please re-install Spotify then run "spicetify backup"`)
129+
}
127130
os.Exit(1)
128131
} else if curBackupStatus == backupstatus.OUTDATED {
129-
if !quiet {
130-
utils.PrintWarning("Spotify version and backup version are mismatched.")
131-
if !utils.ReadAnswer("Continue restoring anyway? [y/N] ", false) {
132-
os.Exit(1)
133-
}
132+
utils.PrintWarning("Spotify version and backup version are mismatched.")
133+
if curSpotifystatus == spotifystatus.STOCK {
134+
utils.PrintInfo(`Spotify is at stock state. Run "spicetify backup" to backup current Spotify version.`)
135+
}
136+
if !quiet && !utils.ReadAnswer("Continue restoring anyway? [y/N] ", false) {
137+
os.Exit(1)
134138
}
135139
}
136140

0 commit comments

Comments
 (0)