mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 17:37:36 +03:00
remove journal when adding a new sync on an existing folder
This commit is contained in:
parent
d7d77a49fc
commit
12148b5c9b
3 changed files with 29 additions and 1 deletions
|
@ -698,6 +698,8 @@ void Application::slotAddFolder()
|
|||
_folderMan->setSyncEnabled(true); // do start sync again.
|
||||
|
||||
if( goodData ) {
|
||||
if (!FolderMan::ensureJournalGone( sourceFolder ))
|
||||
return;
|
||||
_folderMan->addFolderDefinition( backend, alias, sourceFolder, targetPath, onlyThisLAN );
|
||||
Folder *f = _folderMan->setupFolderFromConfigFile( alias );
|
||||
if( f ) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#endif
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QtCore>
|
||||
|
||||
namespace Mirall {
|
||||
|
@ -125,6 +126,24 @@ void FolderMan::wipeAllJournals()
|
|||
}
|
||||
}
|
||||
|
||||
bool FolderMan::ensureJournalGone(const QString &localPath)
|
||||
{
|
||||
|
||||
// remove old .csync_journal file
|
||||
QString stateDbFile = localPath+QLatin1String(".csync_journal.db");
|
||||
while (!QFile::remove(stateDbFile)) {
|
||||
int ret = QMessageBox::warning(0, tr("Could not reset folder state"),
|
||||
tr("An old sync journal '%1' was found, "
|
||||
"but could not be removed. Please make sure "
|
||||
"that no application is currently using it.")
|
||||
.arg(QDir::fromNativeSeparators(stateDbFile)),
|
||||
QMessageBox::Retry|QMessageBox::Abort);
|
||||
if (ret == QMessageBox::Abort) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FolderMan::terminateCurrentSync()
|
||||
{
|
||||
if( !_currentSyncFolder.isEmpty() ) {
|
||||
|
@ -243,7 +262,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
|
|||
folder->setConfigFile(file);
|
||||
} else {
|
||||
qWarning() << "unknown backend" << backend;
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,13 @@ public:
|
|||
*/
|
||||
void wipeAllJournals();
|
||||
|
||||
/**
|
||||
* Ensures that a given directory does not contain a .csync_journal.
|
||||
*
|
||||
* @returns false if the journal could not be removed, false otherwise.
|
||||
*/
|
||||
static bool ensureJournalGone(const QString &path);
|
||||
|
||||
/**
|
||||
* Creates a new and empty local directory.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue