mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
FolderMan: Delete old journal file when adding folder. #2606
This commit is contained in:
parent
4559bb5553
commit
84e5ad7346
4 changed files with 23 additions and 12 deletions
|
@ -202,10 +202,9 @@ void AccountSettings::slotFolderWizardAccepted()
|
|||
QStringList selectiveSyncBlackList
|
||||
= folderWizard->property("selectiveSyncBlackList").toStringList();
|
||||
|
||||
if (!FolderMan::ensureJournalGone( sourceFolder ))
|
||||
if (!folderMan->addFolderDefinition(alias, sourceFolder, targetPath, selectiveSyncBlackList))
|
||||
return;
|
||||
|
||||
folderMan->addFolderDefinition(alias, sourceFolder, targetPath, selectiveSyncBlackList );
|
||||
Folder *f = folderMan->setupFolderFromConfigFile( alias );
|
||||
slotAddFolder( f );
|
||||
folderMan->setSyncEnabled(true);
|
||||
|
|
|
@ -234,6 +234,7 @@ bool FolderMan::ensureJournalGone(const QString &localPath)
|
|||
// remove old .csync_journal file
|
||||
QString stateDbFile = localPath+QLatin1String("/.csync_journal.db");
|
||||
while (QFile::exists(stateDbFile) && !QFile::remove(stateDbFile)) {
|
||||
qDebug() << "Could not remove old db file at" << 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 "
|
||||
|
@ -650,9 +651,12 @@ void FolderMan::slotFolderSyncFinished( const SyncResult& )
|
|||
QTimer::singleShot(200, this, SLOT(slotStartScheduledFolderSync()));
|
||||
}
|
||||
|
||||
void FolderMan::addFolderDefinition(const QString& alias, const QString& sourceFolder,
|
||||
const QString& targetPath, const QStringList &selectiveSyncBlackList )
|
||||
bool FolderMan::addFolderDefinition(const QString& alias, const QString& sourceFolder,
|
||||
const QString& targetPath, const QStringList& selectiveSyncBlackList)
|
||||
{
|
||||
if (! ensureJournalGone(sourceFolder))
|
||||
return false;
|
||||
|
||||
QString escapedAlias = escapeAlias(alias);
|
||||
// Create a settings file named after the alias
|
||||
QSettings settings( _folderConfigPath + QLatin1Char('/') + escapedAlias, QSettings::IniFormat);
|
||||
|
@ -664,6 +668,8 @@ void FolderMan::addFolderDefinition(const QString& alias, const QString& sourceF
|
|||
settings.setValue(QLatin1String("connection"), Theme::instance()->appName());
|
||||
settings.setValue(QLatin1String("blackList"), selectiveSyncBlackList);
|
||||
settings.sync();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Folder *FolderMan::folderForPath(const QString &path)
|
||||
|
|
|
@ -49,9 +49,13 @@ public:
|
|||
* QString alias
|
||||
* QString sourceFolder on local machine
|
||||
* QString targetPath on remote
|
||||
*
|
||||
* Ensures any existing journal in the sourceFolder is deleted.
|
||||
* Returns true on success.
|
||||
*/
|
||||
void addFolderDefinition(const QString&, const QString&, const QString& ,
|
||||
const QStringList &selectiveSyncBlacklist = QStringList() );
|
||||
bool addFolderDefinition(const QString& alias, const QString& sourceFolder,
|
||||
const QString& targetPath,
|
||||
const QStringList& selectiveSyncBlacklist = QStringList());
|
||||
|
||||
/** Returns the folder which the file or directory stored in path is in */
|
||||
Folder* folderForPath(const QString& path);
|
||||
|
|
|
@ -437,17 +437,19 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
|
|||
// 2.1: startFromScratch: (Re)move local data, clean slate sync
|
||||
if (startFromScratch) {
|
||||
if (ensureStartFromScratch(localFolder)) {
|
||||
folderMan->addFolderDefinition(Theme::instance()->appName(),
|
||||
localFolder, _remoteFolder, _ocWizard->blacklist() );
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
|
||||
if (folderMan->addFolderDefinition(Theme::instance()->appName(),
|
||||
localFolder, _remoteFolder, _ocWizard->blacklist() )) {
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
|
||||
}
|
||||
replaceDefaultAccountWith(newAccount);
|
||||
}
|
||||
}
|
||||
// 2.2: Reinit: Remove journal and start a sync
|
||||
else {
|
||||
folderMan->addFolderDefinition(Theme::instance()->appName(),
|
||||
localFolder, _remoteFolder, _ocWizard->blacklist() );
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
|
||||
if (folderMan->addFolderDefinition(Theme::instance()->appName(),
|
||||
localFolder, _remoteFolder, _ocWizard->blacklist() )) {
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
|
||||
}
|
||||
replaceDefaultAccountWith(newAccount);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue