Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VFS doesn't update mtime for directories #6335

Open
lorenz opened this issue Jul 23, 2022 · 1 comment · May be fixed by #6455
Open

VFS doesn't update mtime for directories #6335

lorenz opened this issue Jul 23, 2022 · 1 comment · May be fixed by #6455

Comments

@lorenz
Copy link

lorenz commented Jul 23, 2022

What is the problem you are having with rclone?

I'm using serve webdav to serve a local directory over WebDAV. This works fine except that the VFS layer doesn't update the mtime (ModTime) of directories even after dir-cache-time has expired. Debugging revealed that the problem is in dir.go:635 where rclone reuses node (which has the old modTime), item (the new value with the correct modTime) is just discarded.

I'm not familiar with the design principles of the rclone VFS layer so I'm not sure what the right fix here is.

What is your rclone version (output from rclone version)

Self-built from revision 2f461f1

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Linux x86_64

@ncw
Copy link
Member

ncw commented Jul 25, 2022

Ah, you mean this code

rclone/vfs/dir.go

Lines 633 to 637 in 2f461f1

case fs.Directory:
// Reuse old dir value if it exists
if node == nil || !node.IsDir() {
node = newDir(d.vfs, d.f, d, item)
}

This needs to do the equivalent of what happens to the file in the lines above

rclone/vfs/dir.go

Lines 627 to 632 in 2f461f1

// Reuse old file value if it exists
if file, ok := node.(*File); node != nil && ok {
file.setObjectNoUpdate(obj)
} else {
node = newFile(d, d.path, obj, name)
}

So it needs to call an equivalent of this

rclone/vfs/file.go

Lines 465 to 471 in 2f461f1

// Update the object but don't update the directory cache - for use by
// the directory cache
func (f *File) setObjectNoUpdate(o fs.Object) {
f.mu.Lock()
f.o = o
f.mu.Unlock()
}

Note that we don't want to just make a new directory node as that will cause there to be two nodes pointing to the same directory which will cause trouble later!

It should be a fairly easy patch if you want to have a go?

lorenz added a commit to lorenz/rclone that referenced this issue Sep 19, 2022
The VFS directory cache layer didn't update directory properties like
the last modified time at all, as the new objects were not used.
The same problem is already solved for files, implement the same
solution for directories.

Fixes rclone#6335
@lorenz lorenz linked a pull request Sep 19, 2022 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants