From 5648f3932af3882acfc495d7a3216bd1b609a676 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Mon, 7 Nov 2022 11:43:03 +0100 Subject: [PATCH] Add a new parameter to set a remote folder Fixes: #10193 --- changelog/unreleased/10193 | 5 +++++ src/cmd/cmd.cpp | 18 ++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 changelog/unreleased/10193 diff --git a/changelog/unreleased/10193 b/changelog/unreleased/10193 new file mode 100644 index 00000000000..45d71398230 --- /dev/null +++ b/changelog/unreleased/10193 @@ -0,0 +1,5 @@ +Change: Don't guess remote folder in owncloudcmd + +The commandline client was modified to explicitly accept remote folder, the remote folder must no longer be encoded in the server url. + +https://github.com/owncloud/client/issues/10193 diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index d097542c16d..a6b7d4ed27f 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -50,6 +50,7 @@ struct CmdOptions { QString source_dir; QUrl target_url; + QString remoteFolder; QString config_directory; QString user; QString password; @@ -74,7 +75,6 @@ struct SyncCTX } CmdOptions options; QUrl credentialFreeUrl; - QString folder; AccountPtr account; QString user; }; @@ -133,7 +133,7 @@ void sync(const SyncCTX &ctx) opt.fillFromEnvironmentVariables(); opt.verifyChunkSizes(); auto engine = new SyncEngine( - ctx.account, ctx.account->davUrl(), ctx.options.source_dir, ctx.folder, db); + ctx.account, ctx.account->davUrl(), ctx.options.source_dir, ctx.options.remoteFolder, db); engine->setSyncOptions(opt); engine->setParent(db); @@ -330,17 +330,17 @@ CmdOptions parseOptions(const QStringList &app_args) parser.addPositionalArgument(QStringLiteral("source_dir"), QStringLiteral("The source dir")); parser.addPositionalArgument(QStringLiteral("server_url"), QStringLiteral("The url to the server")); + parser.addPositionalArgument(QStringLiteral("remote_folder"), QStringLiteral("A remote folder")); parser.process(app_args); const QStringList args = parser.positionalArguments(); - if (args.size() < 2) { + if (args.size() < 2 || args.size() > 3) { parser.showHelp(); exit(1); } - options.target_url = QUrl::fromUserInput(args[1]); options.source_dir = [arg = args[0]] { QFileInfo fi(arg); if (!fi.exists()) { @@ -353,6 +353,10 @@ CmdOptions parseOptions(const QStringList &app_args) } return sourceDir; }(); + options.target_url = QUrl::fromUserInput(args[1]); + if (args.size() == 3) { + options.remoteFolder = args[2]; + } if (parser.isSet(httpproxyOption)) { options.proxy = parser.value(httpproxyOption); @@ -433,12 +437,6 @@ int main(int argc, char **argv) QStringList splitted = tmp.path().split(ctx.account->davPath()); tmp.setPath(splitted.value(0)); tmp.setScheme(tmp.scheme().replace(QLatin1String("owncloud"), QLatin1String("http"))); - - // Remote folders typically start with a / and don't end with one - ctx.folder = QLatin1Char('/') + splitted.value(1); - if (ctx.folder.endsWith(QLatin1Char('/')) && ctx.folder != QLatin1Char('/')) { - ctx.folder.chop(1); - } return tmp; }(); ctx.credentialFreeUrl = baseUrl.adjusted(QUrl::RemoveUserInfo);