Only run rename detection for new files. This skips an expensive check for all updates to existing files. The tradeoff is that we no longer immediately detect renames on top of another file as a rename -- this may instead become a copy+delete operation on the destination. --------- Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
+13
-6
@@ -745,12 +745,19 @@ func (f *folder) scanSubdirsChangedAndNew(ctx context.Context, subDirs []string,
|
||||
switch f.Type {
|
||||
case config.FolderTypeReceiveOnly, config.FolderTypeReceiveEncrypted:
|
||||
default:
|
||||
if nf, ok := f.findRename(ctx, res.File, batch); ok {
|
||||
if ok, err := batch.Update(nf); err != nil {
|
||||
return 0, err
|
||||
} else if ok {
|
||||
changes++
|
||||
batch.markDeleted(nf.Name)
|
||||
// Rename detection is comparatively expensive, so only attempt
|
||||
// it for files that appeared as new on disk during this scan. A
|
||||
// rename that overwrites an existing file (the destination path
|
||||
// already had an entry, so it scans as an update rather than a
|
||||
// new file) is not optimised as a rename.
|
||||
if res.File.New && res.File.Size > 0 {
|
||||
if nf, ok := f.findRename(ctx, res.File, batch); ok {
|
||||
if ok, err := batch.Update(nf); err != nil {
|
||||
return 0, err
|
||||
} else if ok {
|
||||
changes++
|
||||
batch.markDeleted(nf.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user