Skip to content

Commit

Permalink
filesystem: all - use new permission const names
Browse files Browse the repository at this point in the history
  • Loading branch information
djdv committed Nov 26, 2022
1 parent 6c8903f commit 74a87e7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
16 changes: 9 additions & 7 deletions internal/filesystem/ipfscore.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ type (
const ipfsCoreTimeout = 10 * time.Second

func NewIPFS(core coreiface.CoreAPI, systemID ID) *ipfsCoreAPI {
const permissions = readAll | executeAll
return &ipfsCoreAPI{
root: newRoot(s_IRXA, nil),
root: newRoot(permissions, nil),
core: core,
systemID: systemID,
}
Expand Down Expand Up @@ -100,7 +101,7 @@ func (ci *ipfsCoreAPI) openNode(name string,
) (fs.File, error) {
const (
op fserrors.Op = "ipfscore.openNode"
defaultPermissions = s_IRXA
defaultPermissions = readAll | executeAll
)
// stat, err := ci.stat(name, ipldNode)
defaultMtime := ci.root.stat.ModTime()
Expand Down Expand Up @@ -232,7 +233,7 @@ func translateCoreEntry(entry *coreiface.DirEntry) fs.DirEntry {
name: entry.Name,
size: int64(entry.Size),
mode: coreTypeToGoType(entry.Type) |
s_IRXA, // TODO: from root.
readAll | executeAll, // TODO: from root.
modTime: time.Now(), // TODO: from root.
}
}
Expand Down Expand Up @@ -410,12 +411,13 @@ func openUFSNode(name string, core coreiface.CoreAPI, ipldNode ipld.Node,
),
)
}
// TODO: store/get permissions from root.
const permissions = readAll | executeAll
return &coreFile{
stat: staticStat{
name: name,
size: int64(ufsNode.FileSize()),
mode: unixfsTypeToGoType(ufsNode.Type()) |
s_IRXA, // TODO: from root
name: name,
size: int64(ufsNode.FileSize()),
mode: unixfsTypeToGoType(ufsNode.Type()) | permissions,
modTime: time.Now(), // TODO: from root
},
File: fileNode,
Expand Down
3 changes: 2 additions & 1 deletion internal/filesystem/ipfskeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ func (kfs *IPFSKeyAPI) openRoot() (fs.ReadDirFile, error) {
return keys, err
}
)
const permissions = readAll | executeAll
return &keyDirectory{
ipns: kfs.ipns,
stat: staticStat{
name: rootName,
mode: fs.ModeDir | s_IRXA,
mode: fs.ModeDir | permissions,
modTime: time.Now(), // Not really modified, but key-set as-of right now.
},
cancel: cancel,
Expand Down
8 changes: 5 additions & 3 deletions internal/filesystem/ipfsmfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,14 @@ func (mi *IPFSMFS) openFileNode(name string, mfsNode mfs.FSNode, flag int) (fs.F
if err != nil {
return nil, fserrors.New(fserrors.Permission)
}
const permissions = readAll | writeAll | executeAll // TODO: set/get perms from elsewhere.
return &mfsFile{
descriptor: descriptor,
stat: &mfsStat{ // TODO: retrieve metadata from node if present; timestamps from constructor otherwise.
sizeFn: mfsFileIntf.Size,
staticStat: staticStat{
name: path.Base(name),
mode: s_IRXA, // TODO: perms
mode: permissions,
modTime: time.Now(),
},
},
Expand Down Expand Up @@ -223,13 +224,14 @@ func (mi *IPFSMFS) openDirNode(name string, mfsNode mfs.FSNode) (fs.ReadDirFile,
return nil, fserrors.New(fserrors.NotDir) // TODO: convert old-style errors.
}
ctx, cancel := context.WithCancel(context.Background())
const permissions = readAll | writeAll | executeAll // TODO: set/get perms from elsewhere.
return &mfsDirectory{
ctx: ctx, cancel: cancel,
listing: _hackListAsync(ctx, mfsDir),
mfsDir: mfsDir,
stat: &staticStat{ // TODO: retrieve metadata from node if present; timestamps from constructor otherwise.
name: path.Base(name),
mode: fs.ModeDir | s_IRXA, // TODO: perms
mode: fs.ModeDir | permissions,
modTime: time.Now(),
},
}, nil
Expand Down Expand Up @@ -320,7 +322,7 @@ func translateUFSLinkEntry(parent *mfs.Directory, link *ipld.Link) (fs.DirEntry,
typ = fs.ModeSymlink
}
*/
const permissions = s_IRXA // TODO: perms from caller or node if present.
const permissions = readAll | writeAll | executeAll // TODO: perms from caller or node if present.
var (
mode fs.FileMode
size int64
Expand Down
6 changes: 4 additions & 2 deletions internal/filesystem/ipfspins.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (pfs *IPFSPinAPI) openRoot() (fs.ReadDirFile, error) {
}
}
// TODO: retrieve permission from somewhere else. (Passed into FS constructor)
const permissions = s_IRXA
const permissions = readAll | executeAll
stream := &pinStream{
ipfs: pfs.ipfs,
pins: pins,
Expand Down Expand Up @@ -222,9 +222,11 @@ func (pe *pinDirEntry) Info() (fs.FileInfo, error) {
if ipfs := pe.ipfs; ipfs != nil {
return fs.Stat(pe.ipfs, pinCid.String())
}
// TODO: permission come from somewhere else.
const permissions = readAll | executeAll
return staticStat{
name: pinCid.String(),
mode: fs.ModeDir | s_IRWXA, // TODO: permission come from somewhere else.
mode: fs.ModeDir | permissions,
modTime: time.Now(),
}, nil
}
Expand Down

0 comments on commit 74a87e7

Please sign in to comment.