mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Do not ignore return values for SyncJournalDB in folder, encryptfolderjob, hydrationjob, and vfs_suffix.
Signed-off-by: allexzander <blackslayer4@gmail.com>
This commit is contained in:
parent
d7950304ee
commit
0cb448cf8e
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user