Browse Source

POSIX: change timestamp on each attribute change

pull/2590/head
chrislu 3 years ago
parent
commit
b44f05a2d0
  1. 4
      weed/filesys/dir.go
  2. 4
      weed/filesys/file.go

4
weed/filesys/dir.go

@ -66,7 +66,7 @@ func (dir *Dir) Attr(ctx context.Context, attr *fuse.Attr) error {
attr.Mode = os.FileMode(entry.Attributes.FileMode) | os.ModeDir attr.Mode = os.FileMode(entry.Attributes.FileMode) | os.ModeDir
attr.Mtime = time.Unix(entry.Attributes.Mtime, 0) attr.Mtime = time.Unix(entry.Attributes.Mtime, 0)
attr.Crtime = time.Unix(entry.Attributes.Crtime, 0) attr.Crtime = time.Unix(entry.Attributes.Crtime, 0)
attr.Ctime = time.Unix(entry.Attributes.Crtime, 0)
attr.Ctime = time.Unix(entry.Attributes.Mtime, 0)
attr.Atime = time.Unix(entry.Attributes.Mtime, 0) attr.Atime = time.Unix(entry.Attributes.Mtime, 0)
attr.Gid = entry.Attributes.Gid attr.Gid = entry.Attributes.Gid
attr.Uid = entry.Attributes.Uid attr.Uid = entry.Attributes.Uid
@ -515,6 +515,8 @@ func (dir *Dir) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fus
entry.Attributes.Mtime = req.Mtime.Unix() entry.Attributes.Mtime = req.Mtime.Unix()
} }
entry.Attributes.Mtime = time.Now().Unix()
return dir.saveEntry(entry) return dir.saveEntry(entry)
} }

4
weed/filesys/file.go

@ -149,21 +149,25 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
if req.Valid.Mode() && entry.Attributes.FileMode != uint32(req.Mode) { if req.Valid.Mode() && entry.Attributes.FileMode != uint32(req.Mode) {
entry.Attributes.FileMode = uint32(req.Mode) entry.Attributes.FileMode = uint32(req.Mode)
entry.Attributes.Mtime = time.Now().Unix()
file.dirtyMetadata = true file.dirtyMetadata = true
} }
if req.Valid.Uid() && entry.Attributes.Uid != req.Uid { if req.Valid.Uid() && entry.Attributes.Uid != req.Uid {
entry.Attributes.Uid = req.Uid entry.Attributes.Uid = req.Uid
entry.Attributes.Mtime = time.Now().Unix()
file.dirtyMetadata = true file.dirtyMetadata = true
} }
if req.Valid.Gid() && entry.Attributes.Gid != req.Gid { if req.Valid.Gid() && entry.Attributes.Gid != req.Gid {
entry.Attributes.Gid = req.Gid entry.Attributes.Gid = req.Gid
entry.Attributes.Mtime = time.Now().Unix()
file.dirtyMetadata = true file.dirtyMetadata = true
} }
if req.Valid.Crtime() { if req.Valid.Crtime() {
entry.Attributes.Crtime = req.Crtime.Unix() entry.Attributes.Crtime = req.Crtime.Unix()
entry.Attributes.Mtime = time.Now().Unix()
file.dirtyMetadata = true file.dirtyMetadata = true
} }

Loading…
Cancel
Save