Merge branch 'master' into 15577-ownership-transfer
[arvados.git] / sdk / go / arvados / fs_site.go
index b5daf7b88381f952caaffd4de186624e19dbeb73..4264be4fa600be7abb05351f506feb00dccac6cc 100644 (file)
@@ -6,6 +6,7 @@ package arvados
 
 import (
        "os"
+       "strings"
        "sync"
        "time"
 )
@@ -20,6 +21,7 @@ type CustomFileSystem interface {
 type customFileSystem struct {
        fileSystem
        root *vdirnode
+       thr  *throttle
 
        staleThreshold time.Time
        staleLock      sync.Mutex
@@ -32,6 +34,7 @@ func (c *Client) CustomFileSystem(kc keepClient) CustomFileSystem {
                fileSystem: fileSystem{
                        fsBackend: keepBackend{apiClient: c, keepClient: kc},
                        root:      root,
+                       thr:       newThrottle(concurrentWriters),
                },
        }
        root.inode = &treenode{
@@ -60,7 +63,7 @@ func (fs *customFileSystem) MountByID(mount string) {
                                        mode:    0755 | os.ModeDir,
                                },
                        },
-                       create: fs.mountCollection,
+                       create: fs.mountByID,
                }, nil
        })
 }
@@ -123,6 +126,16 @@ func (fs *customFileSystem) newNode(name string, perm os.FileMode, modTime time.
        return nil, ErrInvalidOperation
 }
 
+func (fs *customFileSystem) mountByID(parent inode, id string) inode {
+       if strings.Contains(id, "-4zz18-") || pdhRegexp.MatchString(id) {
+               return fs.mountCollection(parent, id)
+       } else if strings.Contains(id, "-j7d0g-") {
+               return fs.newProjectNode(fs.root, id, id)
+       } else {
+               return nil
+       }
+}
+
 func (fs *customFileSystem) mountCollection(parent inode, id string) inode {
        var coll Collection
        err := fs.RequestAndDecode(&coll, "GET", "arvados/v1/collections/"+id, nil, nil)