if (!next.hasData)
break;
- auto entry = query->stringValue(0);
- if (!entry.endsWith(QLatin1Char('/'))) {
- entry.append(QLatin1Char('/'));
- }
+ const auto entry = Utility::trailingSlashPath(query->stringValue(0));
result.append(entry);
}
*ok = true;
// FIXME: add the folder alias in a hoover hint.
// folder->alias() + QLatin1String("/")
- const auto folderTrailingSlash = it.endsWith('/') ? it : it + QChar('/');
+ const auto folderTrailingSlash = Utility::trailingSlashPath(it);
const auto folderWithoutTrailingSlash = it.endsWith('/') ? it.left(it.length() - 1) : it;
const auto escapedFolderString = Utility::escape(folderWithoutTrailingSlash);
const auto escapedFolderName = Utility::escape(folder->alias());
*/
#include "folderstatusmodel.h"
-#include "folderman.h"
#include "accountstate.h"
#include "common/asserts.h"
-#include <theme.h>
-#include <account.h>
+#include "common/utility.h"
+#include "folderman.h"
#include "folderstatusdelegate.h"
+#include <account.h>
+#include <theme.h>
#include <QFileIconProvider>
#include <QVarLengthArray>
parentInfo->_fetched = true;
QUrl url = parentInfo->_folder->remoteUrl();
- QString pathToRemove = url.path();
- if (!pathToRemove.endsWith('/'))
- pathToRemove += '/';
+ const auto pathToRemove = Utility::trailingSlashPath(url.path());
QStringList selectiveSyncBlackList;
bool ok1 = true;
#ifndef MIRALL_FOLDERWATCHER_WIN_H
#define MIRALL_FOLDERWATCHER_WIN_H
-#include <QThread>
+#include "common/utility.h"
#include <QAtomicInt>
+#include <QThread>
#include <windows.h>
namespace OCC {
public:
WatcherThread(const QString &path)
: QThread()
- , _path(path + (path.endsWith(QLatin1Char('/')) ? QString() : QStringLiteral("/")))
+ , _path(Utility::trailingSlashPath(path))
, _directory(0)
, _resultEvent(0)
, _stopEvent(0)
#include <QDesktopServices>
#include <QApplication>
-#include "wizard/owncloudwizardcommon.h"
-#include "wizard/owncloudwizard.h"
-#include "owncloudsetupwizard.h"
-#include "configfile.h"
-#include "folderman.h"
#include "accessmanager.h"
#include "account.h"
-#include "networkjobs.h"
-#include "sslerrordialog.h"
#include "accountmanager.h"
#include "clientproxy.h"
+#include "common/utility.h"
+#include "configfile.h"
#include "filesystem.h"
+#include "folderman.h"
+#include "networkjobs.h"
#include "owncloudgui.h"
+#include "owncloudsetupwizard.h"
+#include "sslerrordialog.h"
+#include "wizard/owncloudwizard.h"
+#include "wizard/owncloudwizardcommon.h"
#include "creds/credentialsfactory.h"
#include "creds/abstractcredentials.h"
}
// remember the local folder to compare later if it changed, but clean first
- QString lf = QDir::fromNativeSeparators(localFolder);
- if (!lf.endsWith(QLatin1Char('/'))) {
- lf.append(QLatin1Char('/'));
- }
-
- _initLocalFolder = lf;
-
+ _initLocalFolder = Utility::trailingSlashPath(QDir::fromNativeSeparators(localFolder));
_ocWizard->setRemoteFolder(_remoteFolder);
const auto isEnforcedServerSetup =
* for more details.
*/
#include "selectivesyncdialog.h"
-#include "folder.h"
#include "account.h"
+#include "common/utility.h"
+#include "configfile.h"
+#include "folder.h"
+#include "folderman.h"
#include "networkjobs.h"
#include "theme.h"
-#include "folderman.h"
-#include "configfile.h"
#include <QDialogButtonBox>
-#include <QVBoxLayout>
-#include <QTreeWidget>
-#include <qpushbutton.h>
#include <QFileIconProvider>
#include <QHeaderView>
-#include <QSettings>
+#include <QLabel>
#include <QScopedValueRollback>
+#include <QSettings>
+#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include <QLabel>
#include <QVBoxLayout>
+#include <qpushbutton.h>
namespace OCC {
auto *root = dynamic_cast<SelectiveSyncTreeViewItem *>(_folderTree->topLevelItem(0));
QUrl url = _account->davUrl();
- QString pathToRemove = url.path();
- if (!pathToRemove.endsWith('/')) {
- pathToRemove.append('/');
- }
+ auto pathToRemove = Utility::trailingSlashPath(url.path());
pathToRemove.append(_folderPath);
if (!_folderPath.isEmpty())
pathToRemove.append('/');
*/
#include "socketuploadjob.h"
+#include "common/utility.h"
#include "socketapi_p.h"
#include "accountmanager.h"
SyncOptions opt;
opt.fillFromEnvironmentVariables();
opt.verifyChunkSizes();
- _engine = new SyncEngine(account->account(), _localPath.endsWith(QLatin1Char('/')) ? _localPath : _localPath + QLatin1Char('/'), opt, _remotePath, _db);
+ _engine = new SyncEngine(account->account(), Utility::trailingSlashPath(_localPath), opt, _remotePath, _db);
_engine->setParent(_db);
connect(_engine, &OCC::SyncEngine::itemCompleted, this, [this](const OCC::SyncFileItemPtr item) {
#include <QNetworkProxyFactory>
#include <QScreen>
-#include "owncloudwizard.h"
+#include "account.h"
+#include "common/utility.h"
#include "creds/webflowcredentials.h"
+#include "owncloudwizard.h"
#include "webview.h"
-#include "account.h"
namespace OCC {
if (_ocWizard->registration()) {
url = "https://nextcloud.com/register";
} else {
- url = _ocWizard->ocUrl();
- if (!url.endsWith('/')) {
- url += "/";
- }
- url += "index.php/login/flow";
+ url = Utility::trailingSlashPath(_ocWizard->ocUrl()) + "index.php/login/flow";
}
qCInfo(lcWizardWebiewPage()) << "Url to auth at: " << url;
_webView->setUrl(QUrl(url));
_confDir = newLocation;
}
}
- QString dir = _confDir;
- if (!dir.endsWith(QLatin1Char('/')))
- dir.append(QLatin1Char('/'));
- return dir;
+ return Utility::trailingSlashPath(_confDir);
}
static const QLatin1String exclFile("sync-exclude.lst");
{
bool ok = false;
- const auto pathWithTrailingSpace = path.endsWith(QLatin1Char('/')) ? path : path + QLatin1Char('/');
+ const auto pathWithTrailingSpace = Utility::trailingSlashPath(path);
auto blackListSet = _discoveryData->_statedb->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok).toSet();
blackListSet.insert(pathWithTrailingSpace);
*/
#include "discoveryphase.h"
+#include "common/utility.h"
#include "configfile.h"
#include "discovery.h"
#include "helpers.h"
}
// it is not too big, put it in the white list (so we will not do more query for the children) and and do not block.
- static const auto slash = QLatin1Char('/');
- const auto sanitisedPath = path.endsWith(slash) ? path : path + slash;
+ const auto sanitisedPath = Utility::trailingSlashPath(path);
_selectiveSyncWhiteList.insert(std::upper_bound(_selectiveSyncWhiteList.begin(), _selectiveSyncWhiteList.end(), sanitisedPath), sanitisedPath);
return callback(false);
});
#include <QMutex>
#include <QNetworkReply>
+#include "accountfwd.h"
+#include "bandwidthmanager.h"
+#include "common/syncjournaldb.h"
+#include "common/utility.h"
#include "csync.h"
+#include "progressdispatcher.h"
#include "syncfileitem.h"
-#include "common/syncjournaldb.h"
-#include "bandwidthmanager.h"
-#include "accountfwd.h"
#include "syncoptions.h"
-#include "progressdispatcher.h"
#include <deque>
bool _finishedEmited = false; // used to ensure that finished is only emitted once
public:
- OwncloudPropagator(AccountPtr account, const QString &localDir,
- const QString &remoteFolder, SyncJournalDb *progressDb,
- QSet<QString> &bulkUploadBlackList)
+ OwncloudPropagator(AccountPtr account, const QString &localDir, const QString &remoteFolder, SyncJournalDb *progressDb, QSet<QString> &bulkUploadBlackList)
: _journal(progressDb)
, _bandwidthManager(this)
, _chunkSize(10 * 1000 * 1000) // 10 MB, overridden in setSyncOptions
, _account(account)
- , _localDir((localDir.endsWith(QChar('/'))) ? localDir : localDir + '/')
- , _remoteFolder((remoteFolder.endsWith(QChar('/'))) ? remoteFolder : remoteFolder + '/')
+ , _localDir(Utility::trailingSlashPath(localDir))
+ , _remoteFolder(Utility::trailingSlashPath(remoteFolder))
, _bulkUploadBlackList(bulkUploadBlackList)
{
qRegisterMetaType<PropagatorJob::AbortType>("PropagatorJob::AbortType");
_discoveryPhase->_excludes->reloadExcludeFiles();
}
_discoveryPhase->_statedb = _journal;
- _discoveryPhase->_localDir = _localPath;
- if (!_discoveryPhase->_localDir.endsWith('/'))
- _discoveryPhase->_localDir+='/';
- _discoveryPhase->_remoteFolder = _remotePath;
- if (!_discoveryPhase->_remoteFolder.endsWith('/'))
- _discoveryPhase->_remoteFolder+='/';
+ _discoveryPhase->_localDir = Utility::trailingSlashPath(_localPath);
+ _discoveryPhase->_remoteFolder = Utility::trailingSlashPath(_remotePath);
_discoveryPhase->_syncOptions = _syncOptions;
_discoveryPhase->_shouldDiscoverLocaly = [this](const QString &path) {
const auto result = shouldDiscoverLocally(path);
QString Theme::conflictHelpUrl() const
{
- auto baseUrl = helpUrl();
- if (baseUrl.isEmpty())
+ const auto baseUrl = helpUrl();
+ if (baseUrl.isEmpty()) {
return QString();
- if (!baseUrl.endsWith('/'))
- baseUrl.append('/');
- return baseUrl + QStringLiteral("conflicts.html");
+ }
+
+ return Utility::trailingSlashPath(baseUrl) + QStringLiteral("conflicts.html");
}
QString Theme::overrideServerUrl() const
*/
#include "syncenginetestutils.h"
-#include "httplogger.h"
#include "accessmanager.h"
+#include "common/utility.h"
#include "gui/sharepermissions.h"
+#include "httplogger.h"
#include <QJsonDocument>
#include <QJsonArray>
QString FileInfo::absolutePath() const
{
- if (parentPath.endsWith(QLatin1Char('/'))) {
- return parentPath + name;
- } else {
- return parentPath + QLatin1Char('/') + name;
- }
+ return OCC::Utility::trailingSlashPath(parentPath) + name;
}
void FileInfo::fixupParentPathRecursively()
auto writeFileResponse = [&](const FileInfo &fileInfo) {
xml.writeStartElement(davUri, QStringLiteral("response"));
- auto url = QString::fromUtf8(QUrl::toPercentEncoding(fileInfo.absolutePath(), "/"));
- if (!url.endsWith(QChar('/'))) {
- url.append(QChar('/'));
- }
+ const auto url = OCC::Utility::trailingSlashPath(QString::fromUtf8(QUrl::toPercentEncoding(fileInfo.absolutePath(), "/")));
const auto href = OCC::Utility::concatUrlPath(prefix, url).path();
xml.writeTextElement(davUri, QStringLiteral("href"), href);
xml.writeStartElement(davUri, QStringLiteral("propstat"));
QString FakeFolder::localPath() const
{
// SyncEngine wants a trailing slash
- if (_tempDir.path().endsWith(QLatin1Char('/')))
- return _tempDir.path();
- return _tempDir.path() + QLatin1Char('/');
+ return OCC::Utility::trailingSlashPath(_tempDir.path());
}
void FakeFolder::scheduleSync()