Skip to content

Commit afdf3fc

Browse files
author
JojiiOfficial
committed
fix folder/file attributes
1 parent 9dc3fee commit afdf3fc

File tree

4 files changed

+57
-59
lines changed

4 files changed

+57
-59
lines changed

dmfs/fsFile.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

dmfs/fsGroup.go

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020
var (
2121
_ = (fs.NodeReaddirer)((*groupNode)(nil))
2222
_ = (fs.NodeLookuper)((*groupNode)(nil))
23-
_ = (fs.NodeGetattrer)((*groupNode)(nil))
23+
_ = (fs.NodeUnlinker)((*groupNode)(nil))
2424
)
2525

2626
type groupNode struct {
@@ -98,13 +98,13 @@ func (groupNode *groupNode) Lookup(ctx context.Context, name string, out *fuse.E
9898

9999
child := groupNode.GetChild(name)
100100
if child == nil {
101-
child = groupNode.NewInode(ctx, &fileInode{
102-
file: file,
103-
}, fs.StableAttr{
101+
child = groupNode.NewInode(ctx, &fs.Inode{}, fs.StableAttr{
104102
Mode: syscall.S_IFREG,
105103
})
106104
}
107105

106+
groupNode.setFileAttrs(file, out)
107+
108108
return child, 0
109109
}
110110

@@ -118,9 +118,32 @@ func (groupNode *groupNode) findFile(name string) *libdatamanager.FileResponseIt
118118
return nil
119119
}
120120

121-
// Set file attributes
122-
func (groupNode *groupNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
123-
out.Mode = 0700
124-
data.setUserAttr(out)
121+
// Set file attributes for files
122+
func (groupNode *groupNode) setFileAttrs(file *libdatamanager.FileResponseItem, out *fuse.EntryOut) {
123+
out.Size = uint64(file.Size)
124+
125+
// Times
126+
out.Ctime = uint64(file.CreationDate.Unix())
127+
out.Mtime = out.Ctime
128+
out.Atime = out.Ctime
129+
130+
out.Mode = 0600
131+
132+
out.Uid = data.uid
133+
out.Gid = data.gid
134+
out.Owner = fuse.Owner{
135+
Gid: data.gid,
136+
Uid: data.uid,
137+
}
138+
}
139+
140+
// Delete file
141+
func (groupNode *groupNode) Unlink(ctx context.Context, name string) syscall.Errno {
142+
file := groupNode.findFile(name)
143+
if file == nil {
144+
return syscall.ENOENT
145+
}
146+
147+
// TODO delete file remotely
125148
return 0
126149
}

dmfs/fsNamespace.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ func (nsNode *namespaceNode) Lookup(ctx context.Context, name string, out *fuse.
101101
})
102102
}
103103

104+
nsNode.setGroupFolderAttributes(out)
105+
104106
return child, 0
105107
}
106108

@@ -160,3 +162,14 @@ func (nsNode *namespaceNode) Mkdir(ctx context.Context, name string, mode uint32
160162

161163
return node, 0
162164
}
165+
166+
// Set attributes for group folders
167+
func (nsNode *namespaceNode) setGroupFolderAttributes(out *fuse.EntryOut) {
168+
out.Owner = fuse.Owner{
169+
Gid: data.gid,
170+
Uid: data.uid,
171+
}
172+
out.Gid = data.gid
173+
out.Uid = data.uid
174+
out.Mode = 0700
175+
}

dmfs/fsRoot.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ func (root *rootNode) Lookup(ctx context.Context, name string, out *fuse.EntryOu
134134
})
135135
}
136136

137+
root.setRootNodeAttributes(out)
138+
137139
return child, 0
138140
}
139141

@@ -250,3 +252,14 @@ func (root *rootNode) debug(arg ...interface{}) {
250252
fmt.Println(arg...)
251253
}
252254
}
255+
256+
// Set attributes for namespace folders
257+
func (root *rootNode) setRootNodeAttributes(out *fuse.EntryOut) {
258+
out.Owner = fuse.Owner{
259+
Gid: data.gid,
260+
Uid: data.uid,
261+
}
262+
out.Gid = data.gid
263+
out.Uid = data.uid
264+
out.Mode = 0700
265+
}

0 commit comments

Comments
 (0)