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 {
24 mode: os.ModeDir | 0755,
27 inodes: make(map[string]inode),
30 root.Child("by_id", func(inode) inode {
34 inodes: make(map[string]inode),
38 mode: 0755 | os.ModeDir,
41 create: func(name string) inode {
42 return newEntByID(c, kc, name)
46 return &fileSystem{inode: root}
49 func newEntByID(c *Client, kc keepClient, id string) inode {
51 err := c.RequestAndDecode(&coll, "GET", "arvados/v1/collections/"+id, nil, nil)
55 fs, err := coll.FileSystem(c, kc)
56 fs.(*collectionFileSystem).inode.(*dirnode).fileinfo.name = id
63 type vdirnode struct {
65 create func(string) inode
68 func (vn *vdirnode) Child(name string, _ func(inode) inode) inode {
69 return vn.treenode.Child(name, func(existing inode) inode {
73 return vn.create(name)