Skip to content

Commit

Permalink
Merge pull request #4064 from nextcloud/bugfix/syncStuckOnError
Browse files Browse the repository at this point in the history
Bugfix/sync stuck on error
  • Loading branch information
mgallien authored Dec 10, 2021
2 parents 7e19462 + 8ead035 commit e1d5a2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/libsync/bulkpropagatorjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,12 @@ void BulkPropagatorJob::slotStartUpload(SyncFileItemPtr item,

item->_modtime = FileSystem::getModTime(originalFilePath);
if (item->_modtime <= 0) {
return slotOnErrorStartFolderUnlock(item, SyncFileItem::SoftError, tr("Local file has invalid modified time. Do not upload to the server."));
_pendingChecksumFiles.remove(item->_file);
return slotOnErrorStartFolderUnlock(item, SyncFileItem::NormalError, tr("File %1 has invalid modified time. Do not upload to the server.").arg(QDir::toNativeSeparators(item->_file)));
}
if (prevModtime != item->_modtime) {
propagator()->_anotherSyncNeeded = true;
_pendingChecksumFiles.remove(item->_file);
qDebug() << "trigger another sync after checking modified time of item" << item->_file << "prevModtime" << prevModtime << "Curr" << item->_modtime;
return slotOnErrorStartFolderUnlock(item, SyncFileItem::SoftError, tr("Local file changed during syncing. It will be resumed."));
}
Expand All @@ -292,6 +294,7 @@ void BulkPropagatorJob::slotStartUpload(SyncFileItemPtr item,
// or not yet fully copied to the destination.
if (fileIsStillChanging(*item)) {
propagator()->_anotherSyncNeeded = true;
_pendingChecksumFiles.remove(item->_file);
return slotOnErrorStartFolderUnlock(item, SyncFileItem::SoftError, tr("Local file changed during sync."));
}

Expand Down
12 changes: 6 additions & 6 deletions src/libsync/propagateupload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ void PropagateUploadFileCommon::slotComputeContentChecksum()
// and not the _fileToUpload because we are checking the original file, not there
// probably temporary one.
_item->_modtime = FileSystem::getModTime(filePath);
Q_ASSERT(_item->_modtime > 0);
if (_item->_modtime <= 0) {
qCWarning(lcPropagateUpload()) << "invalid modified time" << _item->_file << _item->_modtime;
slotOnErrorStartFolderUnlock(SyncFileItem::NormalError, tr("File %1 has invalid modified time. Do not upload to the server.").arg(QDir::toNativeSeparators(_item->_file)));
return;
}

const QByteArray checksumType = propagator()->account()->capabilities().preferredUploadChecksumType();
Expand Down Expand Up @@ -392,8 +392,8 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray &transmissionCh
return slotOnErrorStartFolderUnlock(SyncFileItem::SoftError, tr("File Removed (start upload) %1").arg(fullFilePath));
}
if (_item->_modtime <= 0) {
return slotOnErrorStartFolderUnlock(
SyncFileItem::SoftError, tr("Local file has invalid modified time. Do not upload to the server."));
slotOnErrorStartFolderUnlock(SyncFileItem::NormalError, tr("File %1 has invalid modified time. Do not upload to the server.").arg(QDir::toNativeSeparators(_item->_file)));
return;
}
Q_ASSERT(_item->_modtime > 0);
if (_item->_modtime <= 0) {
Expand All @@ -405,8 +405,8 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray &transmissionCh

_item->_modtime = FileSystem::getModTime(originalFilePath);
if (_item->_modtime <= 0) {
return slotOnErrorStartFolderUnlock(
SyncFileItem::SoftError, tr("Local file has invalid modified time. Do not upload to the server."));
slotOnErrorStartFolderUnlock(SyncFileItem::NormalError, tr("File %1 has invalid modified time. Do not upload to the server.").arg(QDir::toNativeSeparators(_item->_file)));
return;
}
Q_ASSERT(_item->_modtime > 0);
if (_item->_modtime <= 0) {
Expand Down

0 comments on commit e1d5a2a

Please sign in to comment.