@@ -519,6 +519,18 @@ bool SyncJournalDb::checkConnect()
519519 return sqlFail (QStringLiteral (" Create table conflicts" ), createQuery);
520520 }
521521
522+ // create the caseconflicts table.
523+ createQuery.prepare (" CREATE TABLE IF NOT EXISTS caseconflicts("
524+ " path TEXT PRIMARY KEY,"
525+ " baseFileId TEXT,"
526+ " baseEtag TEXT,"
527+ " baseModtime INTEGER,"
528+ " basePath TEXT UNIQUE"
529+ " );" );
530+ if (!createQuery.exec ()) {
531+ return sqlFail (QStringLiteral (" Create table caseconflicts" ), createQuery);
532+ }
533+
522534 createQuery.prepare (" CREATE TABLE IF NOT EXISTS version("
523535 " major INTEGER(8),"
524536 " minor INTEGER(8),"
@@ -2201,6 +2213,101 @@ ConflictRecord SyncJournalDb::conflictRecord(const QByteArray &path)
22012213 return entry;
22022214}
22032215
2216+ void SyncJournalDb::setCaseConflictRecord (const ConflictRecord &record)
2217+ {
2218+ QMutexLocker locker (&_mutex);
2219+ if (!checkConnect ())
2220+ return ;
2221+
2222+ const auto query = _queryManager.get (PreparedSqlQueryManager::SetCaseClashConflictRecordQuery, QByteArrayLiteral (" INSERT OR REPLACE INTO caseconflicts "
2223+ " (path, baseFileId, baseModtime, baseEtag, basePath) "
2224+ " VALUES (?1, ?2, ?3, ?4, ?5);" ),
2225+ _db);
2226+ ASSERT (query)
2227+ query->bindValue (1 , record.path );
2228+ query->bindValue (2 , record.baseFileId );
2229+ query->bindValue (3 , record.baseModtime );
2230+ query->bindValue (4 , record.baseEtag );
2231+ query->bindValue (5 , record.initialBasePath );
2232+ ASSERT (query->exec ())
2233+ }
2234+
2235+ ConflictRecord SyncJournalDb::caseConflictRecordByBasePath (const QString &baseNamePath)
2236+ {
2237+ ConflictRecord entry;
2238+
2239+ QMutexLocker locker (&_mutex);
2240+ if (!checkConnect ()) {
2241+ return entry;
2242+ }
2243+ const auto query = _queryManager.get (PreparedSqlQueryManager::GetCaseClashConflictRecordQuery, QByteArrayLiteral (" SELECT path, baseFileId, baseModtime, baseEtag, basePath FROM caseconflicts WHERE basePath=?1;" ), _db);
2244+ ASSERT (query)
2245+ query->bindValue (1 , baseNamePath);
2246+ ASSERT (query->exec ())
2247+ if (!query->next ().hasData )
2248+ return entry;
2249+
2250+ entry.path = query->baValue (0 );
2251+ entry.baseFileId = query->baValue (1 );
2252+ entry.baseModtime = query->int64Value (2 );
2253+ entry.baseEtag = query->baValue (3 );
2254+ entry.initialBasePath = query->baValue (4 );
2255+ return entry;
2256+ }
2257+
2258+ ConflictRecord SyncJournalDb::caseConflictRecordByPath (const QString &path)
2259+ {
2260+ ConflictRecord entry;
2261+
2262+ QMutexLocker locker (&_mutex);
2263+ if (!checkConnect ()) {
2264+ return entry;
2265+ }
2266+ const auto query = _queryManager.get (PreparedSqlQueryManager::GetCaseClashConflictRecordByPathQuery, QByteArrayLiteral (" SELECT path, baseFileId, baseModtime, baseEtag, basePath FROM caseconflicts WHERE path=?1;" ), _db);
2267+ ASSERT (query)
2268+ query->bindValue (1 , path);
2269+ ASSERT (query->exec ())
2270+ if (!query->next ().hasData )
2271+ return entry;
2272+
2273+ entry.path = query->baValue (0 );
2274+ entry.baseFileId = query->baValue (1 );
2275+ entry.baseModtime = query->int64Value (2 );
2276+ entry.baseEtag = query->baValue (3 );
2277+ entry.initialBasePath = query->baValue (4 );
2278+ return entry;
2279+ }
2280+
2281+ void SyncJournalDb::deleteCaseClashConflictByPathRecord (const QString &path)
2282+ {
2283+ QMutexLocker locker (&_mutex);
2284+ if (!checkConnect ())
2285+ return ;
2286+
2287+ const auto query = _queryManager.get (PreparedSqlQueryManager::DeleteCaseClashConflictRecordQuery, QByteArrayLiteral (" DELETE FROM caseconflicts WHERE path=?1;" ), _db);
2288+ ASSERT (query)
2289+ query->bindValue (1 , path);
2290+ ASSERT (query->exec ())
2291+ }
2292+
2293+ QByteArrayList SyncJournalDb::caseClashConflictRecordPaths ()
2294+ {
2295+ QMutexLocker locker (&_mutex);
2296+ if (!checkConnect ()) {
2297+ return {};
2298+ }
2299+
2300+ const auto query = _queryManager.get (PreparedSqlQueryManager::GetAllCaseClashConflictPathQuery, QByteArrayLiteral (" SELECT path FROM caseconflicts;" ), _db);
2301+ ASSERT (query)
2302+ ASSERT (query->exec ())
2303+
2304+ QByteArrayList paths;
2305+ while (query->next ().hasData )
2306+ paths.append (query->baValue (0 ));
2307+
2308+ return paths;
2309+ }
2310+
22042311void SyncJournalDb::deleteConflictRecord (const QByteArray &path)
22052312{
22062313 QMutexLocker locker (&_mutex);
0 commit comments