partage

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/partage.git
Log | Files | Refs | README | LICENSE

commit ca9d0ce95d7260511ac0706f800e3e13feb86c0c
parent fcf55b5e3d89939df728983495fb23c90b453dd6
Author: Willy Goiffon <dev@z3bra.org>
Date:   Tue, 26 Oct 2021 17:53:12 +0200

Provide more info with partage-trash verbose mode

Diffstat:
Mpartage-trash/partage-trash.go | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/partage-trash/partage-trash.go b/partage-trash/partage-trash.go @@ -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) { @@ -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 } @@ -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))) } }