14199: Merge branch 'master' into 14199-copy-from-remote
[arvados.git] / sdk / go / arvados / fs_collection.go
index 1fe4d8f56680a6b51b0e82e973ab7fc2570986f4..f6afadba5b47488dfff41a53ebca31a97e1dc940 100644 (file)
@@ -32,6 +32,7 @@ type CollectionFileSystem interface {
        // prepended to all paths in the returned manifest.
        MarshalManifest(prefix string) (string, error)
 
+       // Total data bytes in all files.
        Size() int64
 }
 
@@ -142,7 +143,7 @@ func (fs *collectionFileSystem) MarshalManifest(prefix string) (string, error) {
 }
 
 func (fs *collectionFileSystem) Size() int64 {
-       return fs.fileSystem.root.(*dirnode).Size()
+       return fs.fileSystem.root.(*dirnode).TreeSize()
 }
 
 // filenodePtr is an offset into a file that is (usually) efficient to
@@ -877,13 +878,15 @@ func (dn *dirnode) createFileAndParents(path string) (fn *filenode, err error) {
        return
 }
 
-func (dn *dirnode) Size() (bytes int64) {
+func (dn *dirnode) TreeSize() (bytes int64) {
        dn.RLock()
        defer dn.RUnlock()
        for _, i := range dn.inodes {
                switch i := i.(type) {
-               case *filenode, *dirnode:
+               case *filenode:
                        bytes += i.Size()
+               case *dirnode:
+                       bytes += i.TreeSize()
                }
        }
        return