1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 // SiteFileSystem returns a FileSystem that maps collections and other
13 // Arvados objects onto a filesystem layout.
15 // This is experimental: the filesystem layout is not stable, and
16 // there are significant known bugs and shortcomings. For example,
17 // although the FileSystem allows files to be added and modified in
18 // collections, these changes are not persistent or visible to other
20 func (c *Client) SiteFileSystem(kc keepClient) FileSystem {
22 fsBackend: keepBackend{apiClient: c, keepClient: kc},
28 mode: os.ModeDir | 0755,
31 inodes: make(map[string]inode),
34 root.Child("by_id", func(inode) inode {
40 inodes: make(map[string]inode),
44 mode: 0755 | os.ModeDir,
47 create: func(name string) inode {
48 return newEntByID(vn, name)
57 func newEntByID(parent inode, id string) inode {
59 err := parent.FS().RequestAndDecode(&coll, "GET", "arvados/v1/collections/"+id, nil, nil)
63 fs, err := coll.FileSystem(parent.FS(), parent.FS())
67 root := fs.(*collectionFileSystem).root.(*dirnode)
68 root.fileinfo.name = id
73 type vdirnode struct {
75 create func(string) inode
78 func (vn *vdirnode) Child(name string, _ func(inode) inode) inode {
79 return vn.treenode.Child(name, func(existing inode) inode {
83 return vn.create(name)