X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8da66eb418af5e0584253a5cdc1ad383e26016e7..75b4699bdfe75c714cc4163e0f726f4987541fa1:/sdk/go/arvados/fs_site.go?ds=sidebyside diff --git a/sdk/go/arvados/fs_site.go b/sdk/go/arvados/fs_site.go index b5daf7b883..7826d335c8 100644 --- a/sdk/go/arvados/fs_site.go +++ b/sdk/go/arvados/fs_site.go @@ -6,6 +6,7 @@ package arvados import ( "os" + "strings" "sync" "time" ) @@ -15,14 +16,18 @@ type CustomFileSystem interface { MountByID(mount string) MountProject(mount, uuid string) MountUsers(mount string) + ForwardSlashNameSubstitution(string) } type customFileSystem struct { fileSystem root *vdirnode + thr *throttle staleThreshold time.Time staleLock sync.Mutex + + forwardSlashNameSubstitution string } func (c *Client) CustomFileSystem(kc keepClient) CustomFileSystem { @@ -32,6 +37,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 +66,7 @@ func (fs *customFileSystem) MountByID(mount string) { mode: 0755 | os.ModeDir, }, }, - create: fs.mountCollection, + create: fs.mountByID, }, nil }) } @@ -91,6 +97,10 @@ func (fs *customFileSystem) MountUsers(mount string) { }) } +func (fs *customFileSystem) ForwardSlashNameSubstitution(repl string) { + fs.forwardSlashNameSubstitution = repl +} + // SiteFileSystem returns a FileSystem that maps collections and other // Arvados objects onto a filesystem layout. // @@ -123,6 +133,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)