Skip to content

Commit

Permalink
move removeOldestWtfFile to wtfbackup.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ldougbmx committed Mar 27, 2022
1 parent 8f7dd0b commit ce1efb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
23 changes: 0 additions & 23 deletions cmd/removeOldestFile.go

This file was deleted.

17 changes: 16 additions & 1 deletion cmd/wtfBackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"log"
"os"
"time"

"wowtools/utilities"
Expand All @@ -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)
Expand All @@ -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()
}
}
}
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ce1efb7

Please sign in to comment.