diff --git a/cmd/removeOldestFile.go b/cmd/removeOldestFile.go deleted file mode 100644 index 5c15346..0000000 --- a/cmd/removeOldestFile.go +++ /dev/null @@ -1,23 +0,0 @@ -package cmd - -import ( - "log" - "os" - "wowtools/utilities" - - "github.com/spf13/viper" -) - -func RemoveOldestWtfZip() { - retentionRate := viper.GetInt("retention_rate") - wtfBackupDir := viper.GetString("backup_dir") + "WTF\\" - fileCount := utilities.GetFileCount(wtfBackupDir) - if fileCount > retentionRate { - oldestFile := utilities.GetOldestFolder(wtfBackupDir) - os.Chdir(wtfBackupDir) - removeFile := os.Remove(oldestFile) - if removeFile != nil { - log.Fatal() - } - } -} diff --git a/cmd/wtfBackup.go b/cmd/wtfBackup.go index 157f1c9..390701d 100644 --- a/cmd/wtfBackup.go +++ b/cmd/wtfBackup.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "log" + "os" "time" "wowtools/utilities" @@ -16,7 +17,7 @@ func WtfBackup() { wtfBackupDir := viper.GetString("backup_dir") + "WTF\\" currentTime := time.Now() folderName := currentTime.Format("2006-01-02") - + removeOldElvuiZip() fmt.Println("Beginning backup of WTF folder") if err := utilities.ZipSource(wtfFolder, wtfBackupDir+folderName+".zip"); err != nil { log.Fatal(err) @@ -29,3 +30,17 @@ func WtfBackup() { } fmt.Println("Folder backup complete") } + +func removeOldestWtfZip() { + retentionRate := viper.GetInt("retention_rate") + wtfBackupDir := viper.GetString("backup_dir") + "WTF\\" + fileCount := utilities.GetFileCount(wtfBackupDir) + if fileCount > retentionRate { + oldestFile := utilities.GetOldestFolder(wtfBackupDir) + os.Chdir(wtfBackupDir) + removeFile := os.Remove(oldestFile) + if removeFile != nil { + log.Fatal() + } + } +} diff --git a/main.go b/main.go index f523929..f5dfb04 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,6 @@ func main() { go utilities.VerifyFolders(viper.GetString("backup_dir")+"WTF", &wg) wg.Wait() - cmd.RemoveOldestWtfZip() cmd.WtfBackup() cmd.UpdateElvUI() utilities.OpenCurseforge()