@@ -1721,7 +1721,9 @@ void SyncJournalDb::deleteStaleFlagsEntries()
17211721 return ;
17221722
17231723 SqlQuery delQuery (" DELETE FROM flags WHERE path != '' AND path NOT IN (SELECT path from metadata);" , _db);
1724- delQuery.exec ();
1724+ if (!delQuery.exec ()) {
1725+ sqlFail (QStringLiteral (" deleteStaleFlagsEntries" ), delQuery);
1726+ }
17251727}
17261728
17271729int SyncJournalDb::errorBlackListEntryCount ()
@@ -1862,14 +1864,18 @@ void SyncJournalDb::setPollInfo(const SyncJournalDb::PollInfo &info)
18621864 qCDebug (lcDb) << " Deleting Poll job" << info._file ;
18631865 SqlQuery query (" DELETE FROM async_poll WHERE path=?" , _db);
18641866 query.bindValue (1 , info._file );
1865- query.exec ();
1867+ if (!query.exec ()) {
1868+ sqlFail (QStringLiteral (" setPollInfo DELETE FROM async_poll" ), query);
1869+ }
18661870 } else {
18671871 SqlQuery query (" INSERT OR REPLACE INTO async_poll (path, modtime, filesize, pollpath) VALUES( ? , ? , ? , ? )" , _db);
18681872 query.bindValue (1 , info._file );
18691873 query.bindValue (2 , info._modtime );
18701874 query.bindValue (3 , info._fileSize );
18711875 query.bindValue (4 , info._url );
1872- query.exec ();
1876+ if (!query.exec ()) {
1877+ sqlFail (QStringLiteral (" setPollInfo INSERT OR REPLACE INTO async_poll" ), query);
1878+ }
18731879 }
18741880}
18751881
@@ -1955,7 +1961,10 @@ void SyncJournalDb::avoidRenamesOnNextSync(const QByteArray &path)
19551961 SqlQuery query (_db);
19561962 query.prepare (" UPDATE metadata SET fileid = '', inode = '0' WHERE " IS_PREFIX_PATH_OR_EQUAL (" ?1" , " path" ));
19571963 query.bindValue (1 , path);
1958- query.exec ();
1964+
1965+ if (!query.exec ()) {
1966+ sqlFail (QStringLiteral (" avoidRenamesOnNextSync path: %1" ).arg (QString::fromUtf8 (path)), query);
1967+ }
19591968
19601969 // We also need to remove the ETags so the update phase refreshes the directory paths
19611970 // on the next sync
@@ -1980,7 +1989,10 @@ void SyncJournalDb::schedulePathForRemoteDiscovery(const QByteArray &fileName)
19801989 // Note: CSYNC_FTW_TYPE_DIR == 2
19811990 query.prepare (" UPDATE metadata SET md5='_invalid_' WHERE " IS_PREFIX_PATH_OR_EQUAL (" path" , " ?1" ) " AND type == 2;" );
19821991 query.bindValue (1 , argument);
1983- query.exec ();
1992+
1993+ if (!query.exec ()) {
1994+ sqlFail (QStringLiteral (" schedulePathForRemoteDiscovery path: %1" ).arg (QString::fromUtf8 (fileName)), query);
1995+ }
19841996
19851997 // Prevent future overwrite of the etags of this folder and all
19861998 // parent folders for this sync
@@ -2009,7 +2021,10 @@ void SyncJournalDb::forceRemoteDiscoveryNextSyncLocked()
20092021 qCInfo (lcDb) << " Forcing remote re-discovery by deleting folder Etags" ;
20102022 SqlQuery deleteRemoteFolderEtagsQuery (_db);
20112023 deleteRemoteFolderEtagsQuery.prepare (" UPDATE metadata SET md5='_invalid_' WHERE type=2;" );
2012- deleteRemoteFolderEtagsQuery.exec ();
2024+
2025+ if (!deleteRemoteFolderEtagsQuery.exec ()) {
2026+ sqlFail (QStringLiteral (" forceRemoteDiscoveryNextSyncLocked" ), deleteRemoteFolderEtagsQuery);
2027+ }
20132028}
20142029
20152030
@@ -2197,10 +2212,12 @@ QByteArray SyncJournalDb::conflictFileBaseName(const QByteArray &conflictName)
21972212 auto conflict = conflictRecord (conflictName);
21982213 QByteArray result;
21992214 if (conflict.isValid ()) {
2200- getFileRecordsByFileId (conflict.baseFileId , [&result](const SyncJournalFileRecord &record) {
2215+ if (! getFileRecordsByFileId (conflict.baseFileId , [&result](const SyncJournalFileRecord &record) {
22012216 if (!record._path .isEmpty ())
22022217 result = record._path ;
2203- });
2218+ })) {
2219+ qCWarning (lcDb) << " conflictFileBaseName failed to getFileRecordsByFileId: " << conflictName;
2220+ }
22042221 }
22052222
22062223 if (result.isEmpty ()) {
@@ -2214,7 +2231,10 @@ void SyncJournalDb::clearFileTable()
22142231 QMutexLocker lock (&_mutex);
22152232 SqlQuery query (_db);
22162233 query.prepare (" DELETE FROM metadata;" );
2217- query.exec ();
2234+
2235+ if (!query.exec ()) {
2236+ sqlFail (QStringLiteral (" clearFileTable" ), query);
2237+ }
22182238}
22192239
22202240void SyncJournalDb::markVirtualFileForDownloadRecursively (const QByteArray &path)
@@ -2228,15 +2248,21 @@ void SyncJournalDb::markVirtualFileForDownloadRecursively(const QByteArray &path
22282248 " (" IS_PREFIX_PATH_OF (" ?1" , " path" ) " OR ?1 == '') "
22292249 " AND type=4;" , _db);
22302250 query.bindValue (1 , path);
2231- query.exec ();
2251+
2252+ if (!query.exec ()) {
2253+ sqlFail (QStringLiteral (" markVirtualFileForDownloadRecursively UPDATE metadata SET type=5 path: %1" ).arg (QString::fromUtf8 (path)), query);
2254+ }
22322255
22332256 // We also must make sure we do not read the files from the database (same logic as in schedulePathForRemoteDiscovery)
22342257 // This includes all the parents up to the root, but also all the directory within the selected dir.
22352258 static_assert (ItemTypeDirectory == 2 , " " );
22362259 query.prepare (" UPDATE metadata SET md5='_invalid_' WHERE "
22372260 " (" IS_PREFIX_PATH_OF (" ?1" , " path" ) " OR ?1 == '' OR " IS_PREFIX_PATH_OR_EQUAL (" path" , " ?1" ) " ) AND type == 2;" );
22382261 query.bindValue (1 , path);
2239- query.exec ();
2262+
2263+ if (!query.exec ()) {
2264+ sqlFail (QStringLiteral (" markVirtualFileForDownloadRecursively UPDATE metadata SET md5='_invalid_' path: %1" ).arg (QString::fromUtf8 (path)), query);
2265+ }
22402266}
22412267
22422268Optional<PinState> SyncJournalDb::PinStateInterface::rawForPath (const QByteArray &path)
@@ -2366,7 +2392,12 @@ SyncJournalDb::PinStateInterface::rawList()
23662392 return {};
23672393
23682394 SqlQuery query (" SELECT path, pinState FROM flags;" , _db->_db );
2369- query.exec ();
2395+
2396+ if (!query.exec ()) {
2397+ qCWarning (lcDb) << " SQL Error" << " PinStateInterface::rawList" << query.error ();
2398+ _db->close ();
2399+ ASSERT (false );
2400+ }
23702401
23712402 QVector<QPair<QByteArray, PinState>> result;
23722403 forever {
0 commit comments