1
0

logClean renamed to logClear. deletedSize and deletedCount are incremented now if there was no error.

This commit is contained in:
Alexander Andreev 2022-03-06 22:00:07 +04:00
parent 34d1a0e24b
commit 03c19bc1c8
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -66,11 +66,11 @@ func main() {
}
defer logErr.Close()
logClean, err := logging.NewLogger(config.Log.Clear, config.Log.ToStdout)
logClear, err := logging.NewLogger(config.Log.Clear, config.Log.ToStdout)
if err != nil {
log.Fatalln("failed to open error logger:", err)
}
defer logClean.Close()
defer logClear.Close()
uploadsDir, err := ioutil.ReadDir(config.Uploads.Directory)
if err != nil {
@ -84,15 +84,16 @@ func main() {
if time.Now().UTC().Sub(entry.ModTime().UTC()) >= time.Duration(config.Uploads.Limits.KeepForHours)*time.Hour {
if err := os.Remove(path.Join(config.Uploads.Directory, entry.Name())); err != nil {
logErr.Println("failed to remove file ", entry.Name(), ": ", err)
} else {
deletedSize += entry.Size()
deletedCount++
}
deletedSize += entry.Size()
deletedCount++
}
}
_, _, cFSz := utils.ConvertFileSize(deletedSize)
if deletedCount > 0 {
logClean.Printf("%d %s", deletedCount, cFSz)
logClear.Printf("%d %s", deletedCount, cFSz)
}
}