import (
"os"
+ "strings"
"sync"
"time"
)
type customFileSystem struct {
fileSystem
root *vdirnode
+ thr *throttle
staleThreshold time.Time
staleLock sync.Mutex
fileSystem: fileSystem{
fsBackend: keepBackend{apiClient: c, keepClient: kc},
root: root,
+ thr: newThrottle(concurrentWriters),
},
}
root.inode = &treenode{
mode: 0755 | os.ModeDir,
},
},
- create: fs.mountCollection,
+ create: fs.mountByID,
}, nil
})
}
func (fs *customFileSystem) MountUsers(mount string) {
fs.root.inode.Child(mount, func(inode) (inode, error) {
- return &usersnode{
+ return &lookupnode{
+ stale: fs.Stale,
+ loadOne: fs.usersLoadOne,
+ loadAll: fs.usersLoadAll,
inode: &treenode{
fs: fs,
parent: fs.root,
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)
}
func (fs *customFileSystem) newProjectNode(root inode, name, uuid string) inode {
- return &projectnode{
- uuid: uuid,
- inode: &treenode{
- fs: fs,
- parent: root,
- inodes: make(map[string]inode),
- fileinfo: fileinfo{
- name: name,
- modTime: time.Now(),
- mode: 0755 | os.ModeDir,
- },
- },
- }
-}
-
-func (fs *customFileSystem) newUserNode(root inode, name, uuid string) inode {
- return &projectnode{
- uuid: uuid,
+ return &lookupnode{
+ stale: fs.Stale,
+ loadOne: func(parent inode, name string) (inode, error) { return fs.projectsLoadOne(parent, uuid, name) },
+ loadAll: func(parent inode) ([]inode, error) { return fs.projectsLoadAll(parent, uuid) },
inode: &treenode{
fs: fs,
parent: root,