mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
parent
7eb43d7f7e
commit
9d7425b201
1 changed files with 28 additions and 0 deletions
|
@ -64,8 +64,12 @@ bool SyncJournalDb::maybeMigrateDb(const QString& localPath, const QString& abso
|
||||||
if( !FileSystem::fileExists(oldDbName) ) {
|
if( !FileSystem::fileExists(oldDbName) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
const QString oldDbNameShm = oldDbName + "-shm";
|
||||||
|
const QString oldDbNameWal = oldDbName + "-wal";
|
||||||
|
|
||||||
const QString newDbName = absoluteJournalPath;
|
const QString newDbName = absoluteJournalPath;
|
||||||
|
const QString newDbNameShm = newDbName + "-shm";
|
||||||
|
const QString newDbNameWal = newDbName + "-wal";
|
||||||
|
|
||||||
// Whenever there is an old db file, migrate it to the new db path.
|
// Whenever there is an old db file, migrate it to the new db path.
|
||||||
// This is done to make switching from older versions to newer versions
|
// This is done to make switching from older versions to newer versions
|
||||||
|
@ -80,12 +84,36 @@ bool SyncJournalDb::maybeMigrateDb(const QString& localPath, const QString& abso
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( FileSystem::fileExists( newDbNameWal ) ) {
|
||||||
|
if( !FileSystem::remove(newDbNameWal, &error) ) {
|
||||||
|
qDebug() << "Database migration: Could not remove db WAL file" << newDbNameWal
|
||||||
|
<< "due to" << error;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( FileSystem::fileExists( newDbNameShm ) ) {
|
||||||
|
if( !FileSystem::remove(newDbNameShm, &error) ) {
|
||||||
|
qDebug() << "Database migration: Could not remove db SHM file" << newDbNameShm
|
||||||
|
<< "due to" << error;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !FileSystem::rename(oldDbName, newDbName, &error) ) {
|
if( !FileSystem::rename(oldDbName, newDbName, &error) ) {
|
||||||
qDebug() << "Database migration: could not rename " << oldDbName
|
qDebug() << "Database migration: could not rename " << oldDbName
|
||||||
<< "to" << newDbName << ":" << error;
|
<< "to" << newDbName << ":" << error;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if( !FileSystem::rename(oldDbNameWal, newDbNameWal, &error) ) {
|
||||||
|
qDebug() << "Database migration: could not rename " << oldDbNameWal
|
||||||
|
<< "to" << newDbNameWal << ":" << error;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if( !FileSystem::rename(oldDbNameShm, newDbNameShm, &error) ) {
|
||||||
|
qDebug() << "Database migration: could not rename " << oldDbNameShm
|
||||||
|
<< "to" << newDbNameShm << ":" << error;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Journal successfully migrated from" << oldDbName << "to" << newDbName;
|
qDebug() << "Journal successfully migrated from" << oldDbName << "to" << newDbName;
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue