From: Matthieu Gallien Date: Thu, 16 Dec 2021 14:28:46 +0000 (+0100) Subject: ensure any errors after calling FileSystem::getModTime are handled X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~237^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3e82466d5e0f698a0b94e828e65a6b0239081bb0;p=nextcloud-desktop.git ensure any errors after calling FileSystem::getModTime are handled be sure that even in release mode no errors when calling getModTime could be ignored Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/bulkpropagatorjob.cpp b/src/libsync/bulkpropagatorjob.cpp index 269a0e6c3..506d2989f 100644 --- a/src/libsync/bulkpropagatorjob.cpp +++ b/src/libsync/bulkpropagatorjob.cpp @@ -164,6 +164,12 @@ void BulkPropagatorJob::doStartUpload(SyncFileItemPtr item, fileToUpload._file = item->_file = item->_renameTarget; fileToUpload._path = propagator()->fullLocalPath(fileToUpload._file); item->_modtime = FileSystem::getModTime(newFilePathAbsolute); + if (item->_modtime <= 0) { + _pendingChecksumFiles.remove(item->_file); + slotOnErrorStartFolderUnlock(item, SyncFileItem::NormalError, tr("File %1 has invalid modified time. Do not upload to the server.").arg(QDir::toNativeSeparators(item->_file))); + checkPropagationIsDone(); + return; + } } const auto remotePath = propagator()->fullRemotePath(fileToUpload._file); diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 38caf0e3c..3f13e42c4 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -772,6 +772,10 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item, QString renameError; auto conflictModTime = FileSystem::getModTime(fn); + if (conflictModTime <= 0) { + *error = tr("Impossible to get modification time for file in conflict %1)").arg(fn); + return false; + } QString conflictUserName; if (account()->capabilities().uploadConflictFiles()) conflictUserName = account()->davDisplayName(); diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index c7f8ff5bf..93a204d34 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -599,6 +599,7 @@ void PropagateDownloadFile::conflictChecksumComputed(const QByteArray &checksumT Q_ASSERT(_item->_modtime > 0); if (_item->_modtime <= 0) { qCWarning(lcPropagateDownload()) << "invalid modified time" << _item->_file << _item->_modtime; + return; } if (_item->_modtime != _item->_previousModtime) { Q_ASSERT(_item->_modtime > 0); @@ -609,6 +610,7 @@ void PropagateDownloadFile::conflictChecksumComputed(const QByteArray &checksumT Q_ASSERT(_item->_modtime > 0); if (_item->_modtime <= 0) { qCWarning(lcPropagateDownload()) << "invalid modified time" << _item->_file << _item->_modtime; + return; } updateMetadata(/*isConflict=*/false); return; diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index b655cfdfb..9202d658b 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -213,6 +213,8 @@ void PropagateUploadFileCommon::start() 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; } }