Implement rclone size for measuring remotes - fixes #153
This commit is contained in:
parent
4712043e26
commit
177dbbc29a
4 changed files with 55 additions and 8 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"mime"
|
||||
"path"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -680,6 +681,15 @@ func Md5sum(f Fs, w io.Writer) error {
|
|||
})
|
||||
}
|
||||
|
||||
// Count counts the objects and their sizes in the Fs
|
||||
func Count(f Fs) (objects int64, size int64, err error) {
|
||||
err = ListFn(f, func(o Object) {
|
||||
atomic.AddInt64(&objects, 1)
|
||||
atomic.AddInt64(&size, o.Size())
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// ListDir lists the directories/buckets/containers in the Fs to the supplied writer
|
||||
func ListDir(f Fs, w io.Writer) error {
|
||||
for dir := range f.ListDir() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue