зеркало из https://github.com/nextcloud/desktop.git
Replace all manual isntancesof adding trailing slash with use of utility method
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Родитель
3b208bf838
Коммит
21656cce17
|
@ -1985,10 +1985,7 @@ QStringList SyncJournalDb::getSelectiveSyncList(SyncJournalDb::SelectiveSyncList
|
|||
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;
|
||||
|
|
|
@ -1514,7 +1514,7 @@ void AccountSettings::refreshSelectiveSyncStatus()
|
|||
// 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());
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
*/
|
||||
|
||||
#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>
|
||||
|
@ -703,9 +704,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
|
|||
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;
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
#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 {
|
||||
|
@ -33,7 +34,7 @@ class WatcherThread : public QThread
|
|||
public:
|
||||
WatcherThread(const QString &path)
|
||||
: QThread()
|
||||
, _path(path + (path.endsWith(QLatin1Char('/')) ? QString() : QStringLiteral("/")))
|
||||
, _path(Utility::trailingSlashPath(path))
|
||||
, _directory(0)
|
||||
, _resultEvent(0)
|
||||
, _stopEvent(0)
|
||||
|
|
|
@ -20,19 +20,20 @@
|
|||
#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"
|
||||
|
@ -125,13 +126,7 @@ void OwncloudSetupWizard::startWizard()
|
|||
}
|
||||
|
||||
// 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 =
|
||||
|
|
|
@ -12,23 +12,23 @@
|
|||
* 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 <QScopedValueRollback>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QLabel>
|
||||
#include <QScopedValueRollback>
|
||||
#include <QSettings>
|
||||
#include <QTreeWidget>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QVBoxLayout>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
@ -203,10 +203,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
|
|||
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('/');
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
|
||||
#include "socketuploadjob.h"
|
||||
#include "common/utility.h"
|
||||
#include "socketapi_p.h"
|
||||
|
||||
#include "accountmanager.h"
|
||||
|
@ -55,7 +56,7 @@ SocketUploadJob::SocketUploadJob(const QSharedPointer<SocketApiJobV2> &job)
|
|||
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) {
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
#include <QNetworkProxyFactory>
|
||||
#include <QScreen>
|
||||
|
||||
#include "owncloudwizard.h"
|
||||
#include "creds/webflowcredentials.h"
|
||||
#include "webview.h"
|
||||
#include "account.h"
|
||||
#include "common/utility.h"
|
||||
#include "creds/webflowcredentials.h"
|
||||
#include "owncloudwizard.h"
|
||||
#include "webview.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
@ -46,11 +47,7 @@ void WebViewPage::initializePage() {
|
|||
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));
|
||||
|
|
|
@ -363,11 +363,8 @@ QString ConfigFile::configPath() const
|
|||
_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");
|
||||
|
|
|
@ -437,7 +437,7 @@ void ProcessDirectoryJob::checkAndUpdateSelectiveSyncListsForE2eeFolders(const Q
|
|||
{
|
||||
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);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
|
||||
#include "discoveryphase.h"
|
||||
#include "common/utility.h"
|
||||
#include "configfile.h"
|
||||
#include "discovery.h"
|
||||
#include "helpers.h"
|
||||
|
@ -122,8 +123,7 @@ void DiscoveryPhase::checkSelectiveSyncNewFolder(const QString &path,
|
|||
}
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
|
|
@ -25,13 +25,14 @@
|
|||
#include <QMutex>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "csync.h"
|
||||
#include "syncfileitem.h"
|
||||
#include "common/syncjournaldb.h"
|
||||
#include "bandwidthmanager.h"
|
||||
#include "accountfwd.h"
|
||||
#include "syncoptions.h"
|
||||
#include "bandwidthmanager.h"
|
||||
#include "common/syncjournaldb.h"
|
||||
#include "common/utility.h"
|
||||
#include "csync.h"
|
||||
#include "progressdispatcher.h"
|
||||
#include "syncfileitem.h"
|
||||
#include "syncoptions.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
|
@ -416,15 +417,13 @@ public:
|
|||
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");
|
||||
|
|
|
@ -617,12 +617,8 @@ void SyncEngine::startSync()
|
|||
_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);
|
||||
|
|
|
@ -408,12 +408,12 @@ QString Theme::helpUrl() const
|
|||
|
||||
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
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
*/
|
||||
|
||||
#include "syncenginetestutils.h"
|
||||
#include "httplogger.h"
|
||||
#include "accessmanager.h"
|
||||
#include "common/utility.h"
|
||||
#include "gui/sharepermissions.h"
|
||||
#include "httplogger.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
@ -285,11 +286,7 @@ QString FileInfo::path() const
|
|||
|
||||
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()
|
||||
|
@ -339,10 +336,7 @@ FakePropfindReply::FakePropfindReply(FileInfo &remoteRootFileInfo, QNetworkAcces
|
|||
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"));
|
||||
|
@ -1178,9 +1172,7 @@ FileInfo FakeFolder::currentLocalState()
|
|||
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()
|
||||
|
|
Загрузка…
Ссылка в новой задаче