Skip to content

Commit 6ddc129

Browse files
committed
Db: Move drop-index to after pragmas are set #6881
1 parent fce0059 commit 6ddc129

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/common/syncjournaldb.cpp

+13-14
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,6 @@ bool SyncJournalDb::checkConnect()
313313
qCInfo(lcDb) << "sqlite3 version" << pragma1.stringValue(0);
314314
}
315315

316-
{
317-
// Future version of the client (2.6) will have an index 'metadata_parent' which
318-
// depends on a custom sqlite function which does not exist yet in 2.5.
319-
// So make sure to remove the index if it exists, otherwise we will crash when inserting
320-
// rows in the metadata database.
321-
// This needs to be done before the synchronous mode is enabled.
322-
// The 2.6 client will anyway re-creates this index if it does not exist.
323-
SqlQuery query(_db);
324-
query.prepare("DROP INDEX IF EXISTS metadata_parent;");
325-
if (!query.exec()) {
326-
return sqlFail("updateMetadataTableStructure: remove index metadata_parent", query);
327-
}
328-
}
329-
330316
// Set locking mode to avoid issues with WAL on Windows
331317
static QByteArray locking_mode_env = qgetenv("OWNCLOUD_SQLITE_LOCKING_MODE");
332318
if (locking_mode_env.isEmpty())
@@ -366,6 +352,19 @@ bool SyncJournalDb::checkConnect()
366352
return sqlFail("Set PRAGMA case_sensitivity", pragma1);
367353
}
368354

355+
{
356+
// Future version of the client (2.6) will have an index 'metadata_parent' which
357+
// depends on a custom sqlite function which does not exist yet in 2.5.
358+
// So make sure to remove the index if it exists, otherwise we will crash when inserting
359+
// rows in the metadata database.
360+
// The 2.6 client will anyway re-creates this index if it does not exist.
361+
SqlQuery query(_db);
362+
query.prepare("DROP INDEX IF EXISTS metadata_parent;");
363+
if (!query.exec()) {
364+
return sqlFail("updateMetadataTableStructure: remove index metadata_parent", query);
365+
}
366+
}
367+
369368
/* Because insert is so slow, we do everything in a transaction, and only need one call to commit */
370369
startTransaction();
371370

0 commit comments

Comments
 (0)