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 <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2021-12-16 15:28:46 +01:00
parent 384c4bb3f8
commit 3e82466d5e
4 changed files with 14 additions and 0 deletions

View file

@ -164,6 +164,12 @@ void BulkPropagatorJob::doStartUpload(SyncFileItemPtr item,
fileToUpload._file = item->_file = item->_renameTarget; fileToUpload._file = item->_file = item->_renameTarget;
fileToUpload._path = propagator()->fullLocalPath(fileToUpload._file); fileToUpload._path = propagator()->fullLocalPath(fileToUpload._file);
item->_modtime = FileSystem::getModTime(newFilePathAbsolute); 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); const auto remotePath = propagator()->fullRemotePath(fileToUpload._file);

View file

@ -772,6 +772,10 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item,
QString renameError; QString renameError;
auto conflictModTime = FileSystem::getModTime(fn); 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; QString conflictUserName;
if (account()->capabilities().uploadConflictFiles()) if (account()->capabilities().uploadConflictFiles())
conflictUserName = account()->davDisplayName(); conflictUserName = account()->davDisplayName();

View file

@ -599,6 +599,7 @@ void PropagateDownloadFile::conflictChecksumComputed(const QByteArray &checksumT
Q_ASSERT(_item->_modtime > 0); Q_ASSERT(_item->_modtime > 0);
if (_item->_modtime <= 0) { if (_item->_modtime <= 0) {
qCWarning(lcPropagateDownload()) << "invalid modified time" << _item->_file << _item->_modtime; qCWarning(lcPropagateDownload()) << "invalid modified time" << _item->_file << _item->_modtime;
return;
} }
if (_item->_modtime != _item->_previousModtime) { if (_item->_modtime != _item->_previousModtime) {
Q_ASSERT(_item->_modtime > 0); Q_ASSERT(_item->_modtime > 0);
@ -609,6 +610,7 @@ void PropagateDownloadFile::conflictChecksumComputed(const QByteArray &checksumT
Q_ASSERT(_item->_modtime > 0); Q_ASSERT(_item->_modtime > 0);
if (_item->_modtime <= 0) { if (_item->_modtime <= 0) {
qCWarning(lcPropagateDownload()) << "invalid modified time" << _item->_file << _item->_modtime; qCWarning(lcPropagateDownload()) << "invalid modified time" << _item->_file << _item->_modtime;
return;
} }
updateMetadata(/*isConflict=*/false); updateMetadata(/*isConflict=*/false);
return; return;

View file

@ -213,6 +213,8 @@ void PropagateUploadFileCommon::start()
Q_ASSERT(_item->_modtime > 0); Q_ASSERT(_item->_modtime > 0);
if (_item->_modtime <= 0) { if (_item->_modtime <= 0) {
qCWarning(lcPropagateUpload()) << "invalid modified time" << _item->_file << _item->_modtime; 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;
} }
} }