Merge pull request #3592 from nextcloud/bugfix/properWebdavUrlOnAccountSetup

in wizard always use the correct way to get dav path
This commit is contained in:
Matthieu Gallien 2021-07-28 12:27:58 +02:00 committed by GitHub
commit d5857730d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 96 deletions

View file

@ -75,7 +75,6 @@ struct CmdOptions
bool useNetrc; bool useNetrc;
bool interactive; bool interactive;
bool ignoreHiddenFiles; bool ignoreHiddenFiles;
bool nonShib;
QString exclude; QString exclude;
QString unsyncedfolders; QString unsyncedfolders;
QString davPath; QString davPath;
@ -188,8 +187,6 @@ void help()
std::cout << " --password, -p [pass] Use [pass] as password" << std::endl; std::cout << " --password, -p [pass] Use [pass] as password" << std::endl;
std::cout << " -n Use netrc (5) for login" << std::endl; std::cout << " -n Use netrc (5) for login" << std::endl;
std::cout << " --non-interactive Do not block execution with interaction" << std::endl; std::cout << " --non-interactive Do not block execution with interaction" << std::endl;
std::cout << " --nonshib Use Non Shibboleth WebDAV authentication" << std::endl;
std::cout << " --davpath [path] Custom themed dav path, overrides --nonshib" << std::endl;
std::cout << " --max-sync-retries [n] Retries maximum n times (default to 3)" << std::endl; std::cout << " --max-sync-retries [n] Retries maximum n times (default to 3)" << std::endl;
std::cout << " --uplimit [n] Limit the upload speed of files to n KB/s" << std::endl; std::cout << " --uplimit [n] Limit the upload speed of files to n KB/s" << std::endl;
std::cout << " --downlimit [n] Limit the download speed of files to n KB/s" << std::endl; std::cout << " --downlimit [n] Limit the download speed of files to n KB/s" << std::endl;
@ -263,10 +260,6 @@ void parseOptions(const QStringList &app_args, CmdOptions *options)
options->exclude = it.next(); options->exclude = it.next();
} else if (option == "--unsyncedfolders" && !it.peekNext().startsWith("-")) { } else if (option == "--unsyncedfolders" && !it.peekNext().startsWith("-")) {
options->unsyncedfolders = it.next(); options->unsyncedfolders = it.next();
} else if (option == "--nonshib") {
options->nonShib = true;
} else if (option == "--davpath" && !it.peekNext().startsWith("-")) {
options->davPath = it.next();
} else if (option == "--max-sync-retries" && !it.peekNext().startsWith("-")) { } else if (option == "--max-sync-retries" && !it.peekNext().startsWith("-")) {
options->restartTimes = it.next().toInt(); options->restartTimes = it.next().toInt();
} else if (option == "--uplimit" && !it.peekNext().startsWith("-")) { } else if (option == "--uplimit" && !it.peekNext().startsWith("-")) {
@ -328,7 +321,6 @@ int main(int argc, char **argv)
options.useNetrc = false; options.useNetrc = false;
options.interactive = true; options.interactive = true;
options.ignoreHiddenFiles = false; // Default is to sync hidden files options.ignoreHiddenFiles = false; // Default is to sync hidden files
options.nonShib = false;
options.restartTimes = 3; options.restartTimes = 3;
options.uplimit = 0; options.uplimit = 0;
options.downlimit = 0; options.downlimit = 0;
@ -352,14 +344,6 @@ int main(int argc, char **argv)
options.target_url.append("/"); options.target_url.append("/");
} }
if (options.nonShib) {
account->setNonShib(true);
}
if (!options.davPath.isEmpty()) {
account->setDavPath(options.davPath);
}
if (!options.target_url.contains(account->davPath())) { if (!options.target_url.contains(account->davPath())) {
options.target_url.append(account->davPath()); options.target_url.append(account->davPath());
} }
@ -461,13 +445,6 @@ int main(int argc, char **argv)
account->setUrl(url); account->setUrl(url);
account->setSslErrorHandler(sslErrorHandler); account->setSslErrorHandler(sslErrorHandler);
// Perform a call to get the capabilities.
if (!options.nonShib) {
// Do not do it if '--nonshib' was passed. This mean we should only connect to the 'nonshib'
// dav endpoint. Since we do not get the capabilities, in that case, this has the additional
// side effect that chunking-ng will be disabled. (because otherwise it would use the new
// 'dav' endpoint instead of the nonshib one (which still use the old chunking)
QEventLoop loop; QEventLoop loop;
auto *job = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/capabilities")); auto *job = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/capabilities"));
QObject::connect(job, &JsonApiJob::jsonReceived, [&](const QJsonDocument &json) { QObject::connect(job, &JsonApiJob::jsonReceived, [&](const QJsonDocument &json) {
@ -494,7 +471,6 @@ int main(int argc, char **argv)
}); });
job->start(); job->start();
loop.exec(); loop.exec();
}
// much lower age than the default since this utility is usually made to be run right after a change in the tests // much lower age than the default since this utility is usually made to be run right after a change in the tests
SyncEngine::minimumFileAgeForUpload = std::chrono::milliseconds(0); SyncEngine::minimumFileAgeForUpload = std::chrono::milliseconds(0);

View file

@ -59,7 +59,6 @@ const char app_password[] = "_app-password";
Account::Account(QObject *parent) Account::Account(QObject *parent)
: QObject(parent) : QObject(parent)
, _capabilities(QVariantMap()) , _capabilities(QVariantMap())
, _davPath(Theme::instance()->webDavPath())
{ {
qRegisterMetaType<AccountPtr>("AccountPtr"); qRegisterMetaType<AccountPtr>("AccountPtr");
qRegisterMetaType<Account *>("Account*"); qRegisterMetaType<Account *>("Account*");
@ -85,18 +84,7 @@ Account::~Account() = default;
QString Account::davPath() const QString Account::davPath() const
{ {
if (capabilities().chunkingNg()) {
// The chunking-ng means the server prefer to use the new webdav URL
return QLatin1String("/remote.php/dav/files/") + davUser() + QLatin1Char('/'); return QLatin1String("/remote.php/dav/files/") + davUser() + QLatin1Char('/');
}
// make sure to have a trailing slash
if (!_davPath.endsWith('/')) {
QString dp(_davPath);
dp.append('/');
return dp;
}
return _davPath;
} }
void Account::setSharedThis(AccountPtr sharedThis) void Account::setSharedThis(AccountPtr sharedThis)
@ -571,15 +559,6 @@ void Account::setServerVersion(const QString &version)
emit serverVersionChanged(this, oldServerVersion, version); emit serverVersionChanged(this, oldServerVersion, version);
} }
void Account::setNonShib(bool nonShib)
{
if (nonShib) {
_davPath = Theme::instance()->webDavPathNonShib();
} else {
_davPath = Theme::instance()->webDavPath();
}
}
void Account::writeAppPasswordOnce(QString appPassword){ void Account::writeAppPasswordOnce(QString appPassword){
if(_wroteAppPassword) if(_wroteAppPassword)
return; return;

View file

@ -124,8 +124,6 @@ public:
* @returns the (themeable) dav path for the account. * @returns the (themeable) dav path for the account.
*/ */
QString davPath() const; QString davPath() const;
void setDavPath(const QString &s) { _davPath = s; }
void setNonShib(bool nonShib);
/** Returns webdav entry URL, based on url() */ /** Returns webdav entry URL, based on url() */
QUrl davUrl() const; QUrl davUrl() const;
@ -329,7 +327,6 @@ private:
static QString _configFileName; static QString _configFileName;
QString _davPath; // defaults to value from theme, might be overwritten in brandings
ClientSideEncryption _e2e; ClientSideEncryption _e2e;
/// Used in RemoteWipe /// Used in RemoteWipe

View file

@ -643,16 +643,6 @@ bool Theme::wizardSelectiveSyncDefaultNothing() const
return false; return false;
} }
QString Theme::webDavPath() const
{
return QLatin1String("remote.php/dav/");
}
QString Theme::webDavPathNonShib() const
{
return QLatin1String("remote.php/nonshib-webdav/");
}
bool Theme::linkSharing() const bool Theme::linkSharing() const
{ {
return true; return true;

View file

@ -337,15 +337,6 @@ public:
*/ */
virtual bool wizardHideExternalStorageConfirmationCheckbox() const; virtual bool wizardHideExternalStorageConfirmationCheckbox() const;
/**
* Alternative path on the server that provides access to the webdav capabilities
*
* Attention: Make sure that this string does NOT have a leading slash and that
* it has a trailing slash, for example "remote.php/dav/".
*/
virtual QString webDavPath() const;
virtual QString webDavPathNonShib() const;
/** /**
* @brief Sharing options * @brief Sharing options
* *

View file

@ -214,12 +214,13 @@ private slots:
if (verb == "PROPFIND") { if (verb == "PROPFIND") {
auto data = stream->readAll(); auto data = stream->readAll();
if (data.contains("data-fingerprint")) { if (data.contains("data-fingerprint")) {
if (request.url().path().endsWith("dav/")) if (request.url().path().endsWith("dav/files/admin/")) {
++fingerprintRequests; ++fingerprintRequests;
else } else {
fingerprintRequests = -10000; // fingerprint queried on incorrect path fingerprintRequests = -10000; // fingerprint queried on incorrect path
} }
} }
}
return nullptr; return nullptr;
}); });

View file

@ -91,7 +91,7 @@ private slots:
auto oldLocalState = fakeFolder.currentLocalState(); auto oldLocalState = fakeFolder.currentLocalState();
auto oldRemoteState = fakeFolder.currentRemoteState(); auto oldRemoteState = fakeFolder.currentRemoteState();
QString errorFolder = "dav/B"; QString errorFolder = "dav/files/admin/B";
QString fatalErrorPrefix = "Server replied with an error while reading directory 'B' : "; QString fatalErrorPrefix = "Server replied with an error while reading directory 'B' : ";
fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *) fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *)
-> QNetworkReply *{ -> QNetworkReply *{
@ -133,7 +133,7 @@ private slots:
// //
// Check the same discovery error on the sync root // Check the same discovery error on the sync root
// //
errorFolder = "dav/"; errorFolder = "dav/files/admin/";
fatalErrorPrefix = "Server replied with an error while reading directory '' : "; fatalErrorPrefix = "Server replied with an error while reading directory '' : ";
errorSpy.clear(); errorSpy.clear();
QVERIFY(!fakeFolder.syncOnce()); QVERIFY(!fakeFolder.syncOnce());