19362: Sync s3 updates to long-lived session for same token.
[arvados.git] / sdk / go / arvados / fs_site.go
index 716ef34e26098771c44f99c46aeea593ce3e87fb..6719488e23b0dc403dfe3cf9121c973b4bea76a2 100644 (file)
@@ -266,6 +266,8 @@ func (fs *customFileSystem) collectionSingleton(id string) (inode, error) {
                return n, nil
        }
        fs.byID[id] = cfs
+       fs.byIDRoot.Lock()
+       defer fs.byIDRoot.Unlock()
        fs.byIDRoot.Child(id, func(inode) (inode, error) { return cfs, nil })
        return cfs, nil
 }
@@ -337,6 +339,18 @@ type hardlink struct {
        name   string
 }
 
+// If the wrapped inode is a filesystem, rootnode returns the wrapped
+// fs's rootnode, otherwise inode itself. This allows
+// (*fileSystem)Rename() to lock the root node of a hardlink-wrapped
+// filesystem.
+func (hl *hardlink) rootnode() inode {
+       if node, ok := hl.inode.(interface{ rootnode() inode }); ok {
+               return node.rootnode()
+       } else {
+               return hl.inode
+       }
+}
+
 func (hl *hardlink) Sync() error {
        if node, ok := hl.inode.(syncer); ok {
                return node.Sync()