leijurv / gb

backup your files properly to google drive and/or s3
GNU Affero General Public License v3.0
36 stars 6 forks source link

Print what file is currently being uploaded #11

Closed babbaj closed 3 years ago

leijurv commented 3 years ago

Actually I forgot that the Stats struct with a mutex existed. In that case, I think there's a cooler way to do it:

    stats.SetCurrentlyUploading(planned.path)
    compAlg := compression.Compress(planned.path, out, io.TeeReader(f, &verify), &verify)
    stats.NoLongerUploading(planned.path)

And the stats struct would just have a cute currentlyUploading map[string]struct{}

Adding one is stats.currentlyUploading[path] = struct{}{} and deleting one is delete(stats.currentlyUploading, path)

This is important because there are multiple upload threads and the current approach would incorrectly leave it on a small file even when a much larger one is in progress, making it misleading.

(then of course you would print out every key in the map, since those are all files that are uploading)