tProvide more info with partage-trash verbose mode - partage - File upload system
(HTM) git clone git://git.z3bra.org/partage.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit ca9d0ce95d7260511ac0706f800e3e13feb86c0c
(DIR) parent fcf55b5e3d89939df728983495fb23c90b453dd6
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Tue, 26 Oct 2021 17:53:12 +0200
Provide more info with partage-trash verbose mode
Diffstat:
M partage-trash/partage-trash.go | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/partage-trash/partage-trash.go b/partage-trash/partage-trash.go
t@@ -24,6 +24,7 @@ var conf struct {
var verbose bool
var count int64
+var deleted int64
var size int64
func readmeta(filename string) (metadata, error) {
t@@ -52,16 +53,22 @@ func checkexpiry(path string, info os.FileInfo, err error) error {
now := time.Now().Unix()
+ count++
+
if meta.Expiry > 0 && now >= meta.Expiry {
if verbose {
expiration := humanize.Time(time.Unix(meta.Expiry, 0))
- log.Printf("%s/%s expired %s\n", conf.filepath, meta.Filename, expiration)
+ log.Printf("%s/%s: expired %s\n", conf.filepath, meta.Filename, expiration)
}
os.Remove(conf.filepath + "/" + meta.Filename)
os.Remove(path)
+ deleted++
return nil
} else {
- count++
+ if verbose {
+ expiration := humanize.Time(time.Unix(meta.Expiry, 0))
+ log.Printf("%s/%s: expire %s\n", conf.filepath, meta.Filename, expiration)
+ }
size += meta.Size
}
t@@ -81,6 +88,6 @@ func main() {
}
if verbose && count > 0 {
- log.Printf("%d file(s) remain on disk (total: %s)", count, humanize.IBytes(uint64(size)))
+ log.Printf("%d/%d file(s) deleted (remaining: %s)", deleted, count, humanize.IBytes(uint64(size)))
}
}