From: Kevin Ottens Date: Mon, 4 Jan 2021 15:23:47 +0000 (+0100) Subject: Don't detect file changes during hydration for virtual files X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~424^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7c8b7db725655b8ee9c5fd334972e49400ea7576;p=nextcloud-desktop.git Don't detect file changes during hydration for virtual files 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 --- diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 06c0c6337..25d6e8e15 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -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 @@ -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.