Skip to content

Commit

Permalink
Don't detect file changes during hydration for virtual files
Browse files Browse the repository at this point in the history
Indeed, that file size will almost always change between the 1 byte
placeholder and the hydrated file. Only when using the CfAPI on Windows
this won't be the case since because it will expose the original size
even for placeholders.

Also worth noting: the suffix backend didn't hit that case since the
filename changes (with suffix for placeholders, without for hydrated
files).

Signed-off-by: Kevin Ottens <[email protected]>
  • Loading branch information
Kevin Ottens committed Jan 14, 2021
1 parent 6e51dcf commit 7c8b7db
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/libsync/propagatedownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,13 @@ void PropagateDownloadFile::downloadFinished()
previousFileExists = false;
}

if (previousFileExists) {
const auto vfs = propagator()->syncOptions()._vfs;

// In the case of an hydration, this size is likely to change for placeholders
// (except with the cfapi backend)
const auto isVirtualDownload = _item->_type == ItemTypeVirtualFileDownload;
const auto isCfApiVfs = vfs && vfs->mode() == Vfs::WindowsCfApi;
if (previousFileExists && (isCfApiVfs || !isVirtualDownload)) {
// Check whether the existing file has changed since the discovery
// phase by comparing size and mtime to the previous values. This
// is necessary to avoid overwriting user changes that happened between
Expand Down Expand Up @@ -1027,7 +1033,6 @@ void PropagateDownloadFile::downloadFinished()
if (_conflictRecord.isValid())
propagator()->_journal->setConflictRecord(_conflictRecord);

auto vfs = propagator()->syncOptions()._vfs;
if (vfs && vfs->mode() == Vfs::WithSuffix) {
// If the virtual file used to have a different name and db
// entry, remove it transfer its old pin state.
Expand Down

0 comments on commit 7c8b7db

Please sign in to comment.