logClean renamed to logClear. deletedSize and deletedCount are incremented now if there was no error.
This commit is contained in:
parent
34d1a0e24b
commit
03c19bc1c8
@ -66,11 +66,11 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer logErr.Close()
|
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 {
|
if err != nil {
|
||||||
log.Fatalln("failed to open error logger:", err)
|
log.Fatalln("failed to open error logger:", err)
|
||||||
}
|
}
|
||||||
defer logClean.Close()
|
defer logClear.Close()
|
||||||
|
|
||||||
uploadsDir, err := ioutil.ReadDir(config.Uploads.Directory)
|
uploadsDir, err := ioutil.ReadDir(config.Uploads.Directory)
|
||||||
if err != nil {
|
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 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 {
|
if err := os.Remove(path.Join(config.Uploads.Directory, entry.Name())); err != nil {
|
||||||
logErr.Println("failed to remove file ", entry.Name(), ": ", err)
|
logErr.Println("failed to remove file ", entry.Name(), ": ", err)
|
||||||
|
} else {
|
||||||
|
deletedSize += entry.Size()
|
||||||
|
deletedCount++
|
||||||
}
|
}
|
||||||
deletedSize += entry.Size()
|
|
||||||
deletedCount++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, cFSz := utils.ConvertFileSize(deletedSize)
|
_, _, cFSz := utils.ConvertFileSize(deletedSize)
|
||||||
|
|
||||||
if deletedCount > 0 {
|
if deletedCount > 0 {
|
||||||
logClean.Printf("%d %s", deletedCount, cFSz)
|
logClear.Printf("%d %s", deletedCount, cFSz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user