[Pkg-owncloud-commits] [owncloud-client] 140/218: Folder settings: Ensure path is cleaned #3811
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Oct 17 14:30:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 8f8bf98ca63c3e3a2bc64101067e22c04e1328c4
Author: Christian Kamm <mail at ckamm.de>
Date: Thu Sep 17 12:14:35 2015 +0200
Folder settings: Ensure path is cleaned #3811
Paths with a trailing backslash lead to a failing sync beforehand.
These paths can appear in some migration scenarios.
---
src/gui/accountsettings.cpp | 3 ++-
src/gui/folder.cpp | 14 ++++++++++++++
src/gui/folder.h | 3 +++
src/gui/owncloudsetupwizard.cpp | 5 +----
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 5209196..e9956f7 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -201,7 +201,8 @@ void AccountSettings::slotFolderWizardAccepted()
FolderDefinition definition;
definition.alias = folderWizard->field(QLatin1String("alias")).toString();
- definition.localPath = folderWizard->field(QLatin1String("sourceFolder")).toString();
+ definition.localPath = FolderDefinition::prepareLocalPath(
+ folderWizard->field(QLatin1String("sourceFolder")).toString());
definition.targetPath = folderWizard->property("targetPath").toString();
{
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 07477e2..d72c990 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -1160,8 +1160,22 @@ bool FolderDefinition::load(QSettings& settings, const QString& alias,
folder->paused = settings.value(QLatin1String("paused")).toBool();
folder->ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), QVariant(true)).toBool();
settings.endGroup();
+
+ // Old settings can contain paths with native separators. In the rest of the
+ // code we assum /, so clean it up now.
+ folder->localPath = prepareLocalPath(folder->localPath);
+
return true;
}
+QString FolderDefinition::prepareLocalPath(const QString& path)
+{
+ QString p = QDir::fromNativeSeparators(path);
+ if (!p.endsWith(QLatin1Char('/'))) {
+ p.append(QLatin1Char('/'));
+ }
+ return p;
+}
+
} // namespace OCC
diff --git a/src/gui/folder.h b/src/gui/folder.h
index 34a0a94..072e359 100644
--- a/src/gui/folder.h
+++ b/src/gui/folder.h
@@ -73,6 +73,9 @@ public:
/// Reads a folder definition from a settings group with the name 'alias'.
static bool load(QSettings& settings, const QString& alias,
FolderDefinition* folder);
+
+ /// Ensure / as separator and trailing /.
+ static QString prepareLocalPath(const QString& path);
};
/**
diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp
index 50a221e..9ff5cf1 100644
--- a/src/gui/owncloudsetupwizard.cpp
+++ b/src/gui/owncloudsetupwizard.cpp
@@ -453,10 +453,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
// is changed.
auto account = applyAccountChanges();
- QString localFolder = QDir::fromNativeSeparators(_ocWizard->localFolder());
- if( !localFolder.endsWith(QLatin1Char('/'))) {
- localFolder.append(QLatin1Char('/'));
- }
+ QString localFolder = FolderDefinition::prepareLocalPath(_ocWizard->localFolder());
bool startFromScratch = _ocWizard->field("OCSyncFromScratch").toBool();
if (!startFromScratch || ensureStartFromScratch(localFolder)) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list