mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
PropagateDownload: Create conflict even if local file changed
Fixes a bug introduced while moving the attribute propagation before the conflict-renaming.
This commit is contained in:
parent
8a8e93827f
commit
797734870f
1 changed files with 17 additions and 13 deletions
|
@ -954,7 +954,8 @@ void PropagateDownloadFile::downloadFinished()
|
||||||
// Accuracy, and we really need the time from the file system. (#3103)
|
// Accuracy, and we really need the time from the file system. (#3103)
|
||||||
_item->_modtime = FileSystem::getModTime(_tmpFile.fileName());
|
_item->_modtime = FileSystem::getModTime(_tmpFile.fileName());
|
||||||
|
|
||||||
if (FileSystem::fileExists(fn)) {
|
bool previousFileExists = FileSystem::fileExists(fn);
|
||||||
|
if (previousFileExists) {
|
||||||
// Preserve the existing file permissions.
|
// Preserve the existing file permissions.
|
||||||
QFileInfo existingFile(fn);
|
QFileInfo existingFile(fn);
|
||||||
if (existingFile.permissions() != _tmpFile.permissions()) {
|
if (existingFile.permissions() != _tmpFile.permissions()) {
|
||||||
|
@ -964,18 +965,6 @@ void PropagateDownloadFile::downloadFinished()
|
||||||
|
|
||||||
// Make the file a hydrated placeholder if possible
|
// Make the file a hydrated placeholder if possible
|
||||||
propagator()->syncOptions()._vfs->convertToPlaceholder(_tmpFile.fileName(), *_item, fn);
|
propagator()->syncOptions()._vfs->convertToPlaceholder(_tmpFile.fileName(), *_item, fn);
|
||||||
|
|
||||||
// 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
|
|
||||||
// the discovery phase and now.
|
|
||||||
const qint64 expectedSize = _item->_previousSize;
|
|
||||||
const time_t expectedMtime = _item->_previousModtime;
|
|
||||||
if (!FileSystem::verifyFileUnchanged(fn, expectedSize, expectedMtime)) {
|
|
||||||
propagator()->_anotherSyncNeeded = true;
|
|
||||||
done(SyncFileItem::SoftError, tr("File has changed since discovery"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the remote permissions
|
// Apply the remote permissions
|
||||||
|
@ -989,6 +978,21 @@ void PropagateDownloadFile::downloadFinished()
|
||||||
done(SyncFileItem::SoftError, error);
|
done(SyncFileItem::SoftError, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
previousFileExists = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousFileExists) {
|
||||||
|
// 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
|
||||||
|
// the discovery phase and now.
|
||||||
|
const qint64 expectedSize = _item->_previousSize;
|
||||||
|
const time_t expectedMtime = _item->_previousModtime;
|
||||||
|
if (!FileSystem::verifyFileUnchanged(fn, expectedSize, expectedMtime)) {
|
||||||
|
propagator()->_anotherSyncNeeded = true;
|
||||||
|
done(SyncFileItem::SoftError, tr("File has changed since discovery"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
|
|
Loading…
Reference in a new issue