Skip to content

Commit

Permalink
Merge pull request #6300 from nextcloud/backport/6297/stable-3.11
Browse files Browse the repository at this point in the history
[stable-3.11] ensure we do not modify a file that has been just uploaded
  • Loading branch information
allexzander authored Dec 14, 2023
2 parents efd0b53 + 3082963 commit 344fc08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)

// Ensure it's a placeholder file on disk
if (item->_type == ItemTypeFile && _syncOptions._vfs->mode() != Vfs::Off) {
const auto result = _syncOptions._vfs->convertToPlaceholder(filePath, *item);
const auto result = _syncOptions._vfs->convertToPlaceholder(filePath, *item, {}, Vfs::UpdateMetadataType::DatabaseMetadata);
if (!result) {
item->_status = SyncFileItem::Status::NormalError;
item->_instruction = CSYNC_INSTRUCTION_ERROR;
Expand Down Expand Up @@ -412,7 +412,7 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
emit itemCompleted(item, ErrorCategory::GenericError);
return;
}
} else if (modificationHappened || prev._modtime != item->_modtime) {
} else if (prev._modtime != item->_modtime) {
if (!FileSystem::setModTime(filePath, item->_modtime)) {
item->_instruction = CSYNC_INSTRUCTION_ERROR;
item->_errorString = tr("Could not update file metadata: %1").arg(filePath);
Expand Down
3 changes: 2 additions & 1 deletion test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ class TestSyncEngine : public QObject
private slots:
void initTestCase()
{
OCC::Logger::instance()->setLogDebug(true);
Logger::instance()->setLogFlush(true);
Logger::instance()->setLogDebug(true);
}

void testFileDownload() {
Expand Down

0 comments on commit 344fc08

Please sign in to comment.