Repository navigation
Description
What happened?
This is a separate issue, originally started in #3897
Copying here:
I recently hit a bug where I was syncing a large folder to my phone which led to syncthing being killed by android. That's fine on its own, but it died in the middle of the temp - delete - rename chain and I lost some of the files. After restart syncthing saw missing files and propagated them as deletions to other machines.
I think that while this is rare, it's still a data loss possibility, especially in folders with no versioning.
Why not do an in-place rename over the file where it's possible to do atomically?
Relevant context:
#3897 (comment)
Why not do an in-place rename over the file where it's possible to do atomically?
Syncthing does exactly that, always. You've probably run into some other funky corner case of user space filesystem shims in Android or something.
@calmh If
lib/model/folder_sendrecv.go:1736doesn't delete the file from disk before the temp rename, what does it do?syncthing/lib/model/folder_sendrecv.go
Lines 1726 to 1737 in b347343
if !curFile.IsDirectory() && !curFile.IsSymlink() && file.InConflictWith(curFile) { // The new file has been changed in conflict with the existing one. We // should file it away as a conflict instead of just removing or // archiving. // Directories and symlinks aren't checked for conflicts. err = f.inWritableDir(func(name string) error { return f.moveForConflict(name, file.ModifiedBy.String(), scanChan) }, curFile.Name) } else { err = f.deleteItemOnDisk(curFile, scanChan) }
Syncthing version
v2.1.7
Platform & operating system
Linux arm64 / Linux x86_64
Browser version
No response
Activity
[-]Possible data loss in conflict handler with no versioning set up[/-][+]Possible data loss in finisher with no versioning set up[/+]