Skip to content

Commit d6d3add

Browse files
committed
Revert "Remove behavior changes."
This reverts commit 84d06ce.
1 parent 84d06ce commit d6d3add

10 files changed

Lines changed: 43 additions & 9 deletions

src/common/syncjournaldb.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ void SyncJournalDb::deleteStaleFlagsEntries()
17221722

17231723
SqlQuery delQuery("DELETE FROM flags WHERE path != '' AND path NOT IN (SELECT path from metadata);", _db);
17241724
if (!delQuery.exec()) {
1725-
qCWarning(lcDb) << QStringLiteral("deleteStaleFlagsEntries") << delQuery.error();
1725+
sqlFail(QStringLiteral("deleteStaleFlagsEntries"), delQuery);
17261726
}
17271727
}
17281728

@@ -1865,7 +1865,7 @@ void SyncJournalDb::setPollInfo(const SyncJournalDb::PollInfo &info)
18651865
SqlQuery query("DELETE FROM async_poll WHERE path=?", _db);
18661866
query.bindValue(1, info._file);
18671867
if (!query.exec()) {
1868-
qCWarning(lcDb) << QStringLiteral("setPollInfo DELETE FROM async_poll") << query.error();
1868+
sqlFail(QStringLiteral("setPollInfo DELETE FROM async_poll"), query);
18691869
}
18701870
} else {
18711871
SqlQuery query("INSERT OR REPLACE INTO async_poll (path, modtime, filesize, pollpath) VALUES( ? , ? , ? , ? )", _db);
@@ -1874,7 +1874,7 @@ void SyncJournalDb::setPollInfo(const SyncJournalDb::PollInfo &info)
18741874
query.bindValue(3, info._fileSize);
18751875
query.bindValue(4, info._url);
18761876
if (!query.exec()) {
1877-
qCWarning(lcDb) << QStringLiteral("setPollInfo INSERT OR REPLACE INTO async_poll") << query.error();
1877+
sqlFail(QStringLiteral("setPollInfo INSERT OR REPLACE INTO async_poll"), query);
18781878
}
18791879
}
18801880
}
@@ -1963,7 +1963,7 @@ void SyncJournalDb::avoidRenamesOnNextSync(const QByteArray &path)
19631963
query.bindValue(1, path);
19641964

19651965
if (!query.exec()) {
1966-
qCWarning(lcDb) << QStringLiteral("avoidRenamesOnNextSync path: %1").arg(QString::fromUtf8(path)) << query.error();
1966+
sqlFail(QStringLiteral("avoidRenamesOnNextSync path: %1").arg(QString::fromUtf8(path)), query);
19671967
}
19681968

19691969
// We also need to remove the ETags so the update phase refreshes the directory paths
@@ -1991,7 +1991,7 @@ void SyncJournalDb::schedulePathForRemoteDiscovery(const QByteArray &fileName)
19911991
query.bindValue(1, argument);
19921992

19931993
if (!query.exec()) {
1994-
qCWarning(lcDb) << QStringLiteral("schedulePathForRemoteDiscovery path: %11").arg(QString::fromUtf8(fileName)) << query.error();
1994+
sqlFail(QStringLiteral("schedulePathForRemoteDiscovery path: %1").arg(QString::fromUtf8(fileName)), query);
19951995
}
19961996

19971997
// Prevent future overwrite of the etags of this folder and all
@@ -2023,7 +2023,7 @@ void SyncJournalDb::forceRemoteDiscoveryNextSyncLocked()
20232023
deleteRemoteFolderEtagsQuery.prepare("UPDATE metadata SET md5='_invalid_' WHERE type=2;");
20242024

20252025
if (!deleteRemoteFolderEtagsQuery.exec()) {
2026-
qCWarning(lcDb) << QStringLiteral("forceRemoteDiscoveryNextSyncLocked") << deleteRemoteFolderEtagsQuery.error();
2026+
sqlFail(QStringLiteral("forceRemoteDiscoveryNextSyncLocked"), deleteRemoteFolderEtagsQuery);
20272027
}
20282028
}
20292029

@@ -2233,7 +2233,7 @@ void SyncJournalDb::clearFileTable()
22332233
query.prepare("DELETE FROM metadata;");
22342234

22352235
if (!query.exec()) {
2236-
qCWarning(lcDb) << QStringLiteral("clearFileTable") << query.error();
2236+
sqlFail(QStringLiteral("clearFileTable"), query);
22372237
}
22382238
}
22392239

@@ -2250,7 +2250,7 @@ void SyncJournalDb::markVirtualFileForDownloadRecursively(const QByteArray &path
22502250
query.bindValue(1, path);
22512251

22522252
if (!query.exec()) {
2253-
qCWarning(lcDb) << QStringLiteral("markVirtualFileForDownloadRecursively UPDATE metadata SET type=5 path: %1").arg(QString::fromUtf8(path)) << query.error();
2253+
sqlFail(QStringLiteral("markVirtualFileForDownloadRecursively UPDATE metadata SET type=5 path: %1").arg(QString::fromUtf8(path)), query);
22542254
}
22552255

22562256
// We also must make sure we do not read the files from the database (same logic as in schedulePathForRemoteDiscovery)
@@ -2261,7 +2261,7 @@ void SyncJournalDb::markVirtualFileForDownloadRecursively(const QByteArray &path
22612261
query.bindValue(1, path);
22622262

22632263
if (!query.exec()) {
2264-
qCWarning(lcDb) << QStringLiteral("markVirtualFileForDownloadRecursively UPDATE metadata SET md5='_invalid_' path: %1").arg(QString::fromUtf8(path)) << query.error();
2264+
sqlFail(QStringLiteral("markVirtualFileForDownloadRecursively UPDATE metadata SET md5='_invalid_' path: %1").arg(QString::fromUtf8(path)), query);
22652265
}
22662266
}
22672267

@@ -2395,6 +2395,8 @@ SyncJournalDb::PinStateInterface::rawList()
23952395

23962396
if (!query.exec()) {
23972397
qCWarning(lcDb) << "SQL Error" << "PinStateInterface::rawList" << query.error();
2398+
_db->close();
2399+
ASSERT(false);
23982400
}
23992401

24002402
QVector<QPair<QByteArray, PinState>> result;

src/gui/folder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ void Folder::implicitlyHydrateFile(const QString &relativepath)
626626
;
627627
if (!_journal.getFileRecord(relativepath.toUtf8(), &record)) {
628628
qCWarning(lcFolder) << "could not get file from local DB" << relativepath;
629+
return;
629630
}
630631
if (!record.isValid()) {
631632
qCInfo(lcFolder) << "Did not find file in db";
@@ -641,6 +642,7 @@ void Folder::implicitlyHydrateFile(const QString &relativepath)
641642
const auto result = _journal.setFileRecord(record);
642643
if (!result) {
643644
qCWarning(lcFolder) << "Error when setting the file record to the database" << record._path << result.error();
645+
return;
644646
}
645647

646648
// Change the file's pin state if it's contradictory to being hydrated

src/libsync/discovery.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
900900
// Not locally, not on the server. The entry is stale!
901901
qCInfo(lcDisco) << "Stale DB entry";
902902
if (!_discoveryData->_statedb->deleteFileRecord(path._original, true)) {
903+
_discoveryData->fatalError(tr("Error while deleting file record %1 from the database").arg(path._original));
903904
qCWarning(lcDisco) << "Failed to delete a file record from the local DB" << path._original;
904905
}
905906
return;

src/libsync/owncloudpropagator.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,13 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
11971197
if (_item->_instruction == CSYNC_INSTRUCTION_RENAME && _item->_originalFile != _item->_renameTarget) {
11981198
if (!propagator()->_journal->deleteFileRecord(_item->_originalFile, true)) {
11991199
qCWarning(lcDirectory) << "could not delete file from local DB" << _item->_originalFile;
1200+
_state = Finished;
1201+
status = _item->_status = SyncFileItem::FatalError;
1202+
_item->_errorString = tr("could not delete file %1 from local DB").arg(_item->_originalFile);
1203+
qCInfo(lcPropagator) << "PropagateDirectory::slotSubJobsFinished"
1204+
<< "emit finished" << status;
1205+
emit finished(status);
1206+
return;
12001207
}
12011208
}
12021209

src/libsync/propagatedownload.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ void PropagateDownloadFile::start()
461461
SyncJournalFileRecord parentRec;
462462
if (!propagator()->_journal->getFileRecord(parentPath, &parentRec)) {
463463
qCWarning(lcPropagateDownload) << "could not get file from local DB" << parentPath;
464+
done(SyncFileItem::NormalError, tr("could not get file %1 from local DB").arg(parentPath));
465+
return;
464466
}
465467

466468
const auto account = propagator()->account();
@@ -507,6 +509,8 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
507509

508510
if (!propagator()->_journal->deleteFileRecord(_item->_originalFile)) {
509511
qCWarning(lcPropagateDownload) << "could not delete file from local DB" << _item->_originalFile;
512+
done(SyncFileItem::NormalError, tr("Could not delete file record %1 from local DB").arg(_item->_originalFile));
513+
return;
510514
}
511515

512516
updateMetadata(false);
@@ -1245,6 +1249,8 @@ void PropagateDownloadFile::downloadFinished()
12451249

12461250
if (!propagator()->_journal->deleteFileRecord(virtualFile)) {
12471251
qCWarning(lcPropagateDownload) << "could not delete file from local DB" << virtualFile;
1252+
done(SyncFileItem::NormalError, tr("Could not delete file record %1 from local DB").arg(virtualFile));
1253+
return;
12481254
}
12491255

12501256
// Move the pin state to the new location

src/libsync/propagateremotedelete.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ void PropagateRemoteDelete::slotDeleteJobFinished()
115115

116116
if (!propagator()->_journal->deleteFileRecord(_item->_originalFile, _item->isDirectory())) {
117117
qCWarning(lcPropagateRemoteDelete) << "could not delete file from local DB" << _item->_originalFile;
118+
done(SyncFileItem::NormalError, tr("Could not delete file record %1 from local DB").arg(_item->_originalFile));
119+
return;
118120
}
119121

120122
propagator()->_journal->commit("Remote Remove");

src/libsync/propagateremotemove.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ void PropagateRemoteMove::finalize()
247247
SyncJournalFileRecord oldRecord;
248248
if (!propagator()->_journal->getFileRecord(_item->_originalFile, &oldRecord)) {
249249
qCWarning(lcPropagateRemoteMove) << "could not get file from local DB" << _item->_originalFile;
250+
done(SyncFileItem::NormalError, tr("could not get file %1 from local DB").arg(_item->_originalFile));
251+
return;
250252
}
251253
auto &vfs = propagator()->syncOptions()._vfs;
252254
auto pinState = vfs->pinState(_item->_originalFile);
@@ -257,6 +259,8 @@ void PropagateRemoteMove::finalize()
257259
// Delete old db data.
258260
if (!propagator()->_journal->deleteFileRecord(_item->_originalFile)) {
259261
qCWarning(lcPropagateRemoteMove) << "could not delete file from local DB" << _item->_originalFile;
262+
done(SyncFileItem::NormalError, tr("Could not delete file record %1 from local DB").arg(_item->_originalFile));
263+
return;
260264
}
261265
if (!vfs->setPinState(_item->_originalFile, PinState::Inherited)) {
262266
qCWarning(lcPropagateRemoteMove) << "Could not set pin state of" << _item->_originalFile << "to inherited";

src/libsync/propagatorjobs.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ void PropagateLocalRemove::start()
130130
propagator()->reportProgress(*_item, 0);
131131
if (!propagator()->_journal->deleteFileRecord(_item->_originalFile, _item->isDirectory())) {
132132
qCWarning(lcPropagateLocalRename) << "could not delete file from local DB" << _item->_originalFile;
133+
done(SyncFileItem::NormalError, tr("Could not delete file record %1 from local DB").arg(_item->_originalFile));
134+
return;
133135
}
134136
propagator()->_journal->commit("Local remove");
135137
done(SyncFileItem::Success);
@@ -249,9 +251,13 @@ void PropagateLocalRename::start()
249251
SyncJournalFileRecord oldRecord;
250252
if (!propagator()->_journal->getFileRecord(_item->_originalFile, &oldRecord)) {
251253
qCWarning(lcPropagateLocalRename) << "could not get file from local DB" << _item->_originalFile;
254+
done(SyncFileItem::NormalError, tr("could not get file %1 from local DB").arg(_item->_originalFile));
255+
return;
252256
}
253257
if (!propagator()->_journal->deleteFileRecord(_item->_originalFile)) {
254258
qCWarning(lcPropagateLocalRename) << "could not delete file from local DB" << _item->_originalFile;
259+
done(SyncFileItem::NormalError, tr("Could not delete file record %1 from local DB").arg(_item->_originalFile));
260+
return;
255261
}
256262

257263
auto &vfs = propagator()->syncOptions()._vfs;

src/libsync/syncengine.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
377377

378378
// Updating the db happens on success
379379
if (!_journal->setFileRecord(rec)) {
380+
item->_status = SyncFileItem::Status::NormalError;
381+
item->_instruction = CSYNC_INSTRUCTION_ERROR;
382+
item->_errorString = tr("Could not set file record to local DB: %1").arg(rec.path());
380383
qCWarning(lcEngine) << "Could not set file record to local DB" << rec.path();
381384
}
382385

src/libsync/vfs/cfapi/hydrationjob.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ void OCC::HydrationJob::finalize(OCC::VfsCfApi *vfs)
291291
SyncJournalFileRecord record;
292292
if (!_journal->getFileRecord(_folderPath, &record)) {
293293
qCWarning(lcHydration) << "could not get file from local DB" << _folderPath;
294+
return;
294295
}
295296
Q_ASSERT(record.isValid());
296297
if (!record.isValid()) {

0 commit comments

Comments
 (0)