From: allexzander Date: Thu, 4 Aug 2022 14:13:59 +0000 (+0300) Subject: Do not ignore return values for SyncJournalDB in folder, encryptfolderjob, hydrationj... X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~262^2~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0cb448cf8e9c878f6ea439aeda009a16be574239;p=nextcloud-desktop.git Do not ignore return values for SyncJournalDB in folder, encryptfolderjob, hydrationjob, and vfs_suffix. Signed-off-by: allexzander --- diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 7229c1ba4..9a50716a1 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -577,7 +577,9 @@ void Folder::slotWatchedPathChanged(const QString &path, ChangeReason reason) SyncJournalFileRecord record; - _journal.getFileRecord(relativePathBytes, &record); + if (!_journal.getFileRecord(relativePathBytes, &record)) { + qCWarning(lcFolder) << "could not get file from local DB" << relativePathBytes; + } if (reason != ChangeReason::UnLock) { // Check that the mtime/size actually changed or there was // an attribute change (pin state) that caused the notification @@ -613,7 +615,11 @@ void Folder::implicitlyHydrateFile(const QString &relativepath) // Set in the database that we should download the file SyncJournalFileRecord record; - _journal.getFileRecord(relativepath.toUtf8(), &record); + ; + if (!_journal.getFileRecord(relativepath.toUtf8(), &record)) { + qCWarning(lcFolder) << "could not get file from local DB" << relativepath; + return; + } if (!record.isValid()) { qCInfo(lcFolder) << "Did not find file in db"; return; @@ -622,8 +628,14 @@ void Folder::implicitlyHydrateFile(const QString &relativepath) qCInfo(lcFolder) << "The file is not virtual"; return; } + record._type = ItemTypeVirtualFileDownload; - _journal.setFileRecord(record); + + const auto result = _journal.setFileRecord(record); + if (!result) { + qCWarning(lcFolder) << "Error when setting the file record to the database" << record._path << result.error(); + return; + } // Change the file's pin state if it's contradictory to being hydrated // (suffix-virtual file's pin state is stored at the hydrated path) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 4f2dc9610..7a59f1fa9 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1430,7 +1430,7 @@ void ProcessDirectoryJob::processFileConflict(const SyncFileItemPtr &item, Proce rec._checksumHeader = serverEntry.checksumHeader; const auto result = _discoveryData->_statedb->setFileRecord(rec); if (!result) { - qCWarning(lcDisco) << "Error when setting the file record to the database" << result.error(); + qCWarning(lcDisco) << "Error when setting the file record to the database" << rec._path << result.error(); } } return; diff --git a/src/libsync/encryptfolderjob.cpp b/src/libsync/encryptfolderjob.cpp index 1a9fc6584..e9a8f4caa 100644 --- a/src/libsync/encryptfolderjob.cpp +++ b/src/libsync/encryptfolderjob.cpp @@ -48,10 +48,18 @@ QString EncryptFolderJob::errorString() const void EncryptFolderJob::slotEncryptionFlagSuccess(const QByteArray &fileId) { SyncJournalFileRecord rec; - _journal->getFileRecord(_path, &rec); - if (rec.isValid()) { - rec._isE2eEncrypted = true; - _journal->setFileRecord(rec); + if (!_journal->getFileRecord(_path, &rec)) { + qCWarning(lcEncryptFolderJob) << "could not get file from local DB" << _path; + } + + if (!rec.isValid()) { + qCWarning(lcEncryptFolderJob) << "No valid record found in local DB for fileId" << fileId; + } + + rec._isE2eEncrypted = true; + const auto result = _journal->setFileRecord(rec); + if (!result) { + qCWarning(lcEncryptFolderJob) << "Error when setting the file record to the database" << rec._path << result.error(); } auto lockJob = new LockEncryptFolderApiJob(_account, fileId, this); diff --git a/src/libsync/vfs/cfapi/hydrationjob.cpp b/src/libsync/vfs/cfapi/hydrationjob.cpp index 0de8967dd..26c8a19e7 100644 --- a/src/libsync/vfs/cfapi/hydrationjob.cpp +++ b/src/libsync/vfs/cfapi/hydrationjob.cpp @@ -289,7 +289,10 @@ void OCC::HydrationJob::finalize(OCC::VfsCfApi *vfs) { // Mark the file as hydrated in the sync journal SyncJournalFileRecord record; - _journal->getFileRecord(_folderPath, &record); + if (!_journal->getFileRecord(_folderPath, &record)) { + qCWarning(lcHydration) << "could not get file from local DB" << _folderPath; + return; + } Q_ASSERT(record.isValid()); if (!record.isValid()) { qCWarning(lcHydration) << "Couldn't find record to update after hydration" << _requestId << _folderPath; @@ -320,7 +323,10 @@ void OCC::HydrationJob::finalize(OCC::VfsCfApi *vfs) // store the actual size of a file that has been decrypted as we will need its actual size when dehydrating it if requested record._fileSize = FileSystem::getSize(localPath() + folderPath()); - _journal->setFileRecord(record); + const auto result = _journal->setFileRecord(record); + if (!result) { + qCWarning(lcHydration) << "Error when setting the file record to the database" << record._path << result.error(); + } } void OCC::HydrationJob::onGetFinished() diff --git a/src/libsync/vfs/suffix/vfs_suffix.cpp b/src/libsync/vfs/suffix/vfs_suffix.cpp index 0ed2ce93b..21a7fd950 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.cpp +++ b/src/libsync/vfs/suffix/vfs_suffix.cpp @@ -45,12 +45,17 @@ void VfsSuffix::startImpl(const VfsSetupParams ¶ms) // that are not marked as a virtual file. These could be real .owncloud // files that were synced before vfs was enabled. QByteArrayList toWipe; - params.journal->getFilesBelowPath("", [&toWipe](const SyncJournalFileRecord &rec) { + if (!params.journal->getFilesBelowPath("", [&toWipe](const SyncJournalFileRecord &rec) { if (!rec.isVirtualFile() && rec._path.endsWith(APPLICATION_DOTVIRTUALFILE_SUFFIX)) toWipe.append(rec._path); - }); - for (const auto &path : toWipe) - params.journal->deleteFileRecord(path); + })) { + qWarning() << "Could not get files below path \"\" from local DB"; + } + for (const auto &path : toWipe) { + if (!params.journal->deleteFileRecord(path)) { + qWarning() << "Failed to delete file record from local DB" << path; + } + } } void VfsSuffix::stop()