From: dheule Date: Wed, 19 Apr 2017 08:32:36 +0000 (+0200) Subject: added owncloudcmd bandwidth limit parameter (#5707) X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~771 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ada2be94f2fe6a14d5aef566f06e30d384d64d2e;p=nextcloud-desktop.git added owncloudcmd bandwidth limit parameter (#5707) --- diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index 5421b2314..553905d8e 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) by Olivier Goffart * Copyright (C) by Klaas Freitag + * Copyright (C) by Daniel Heule * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,6 +68,8 @@ struct CmdOptions { QString unsyncedfolders; QString davPath; int restartTimes; + int downlimit; + int uplimit; }; // we can't use csync_set_userdata because the SyncEngine sets it already. @@ -169,6 +172,8 @@ void help() 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 << " --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 << " -h Sync hidden files,do not ignore them" << std::endl; std::cout << " --version, -v Display version and exit" << std::endl; std::cout << "" << std::endl; @@ -244,6 +249,10 @@ void parseOptions( const QStringList& app_args, CmdOptions *options ) options->davPath = it.next(); } else if( option == "--max-sync-retries" && !it.peekNext().startsWith("-") ) { options->restartTimes = it.next().toInt(); + } else if( option == "--uplimit" && !it.peekNext().startsWith("-") ) { + options->uplimit = it.next().toInt() * 1000; + } else if( option == "--downlimit" && !it.peekNext().startsWith("-") ) { + options->downlimit = it.next().toInt() * 1000; } else { help(); } @@ -297,6 +306,8 @@ int main(int argc, char **argv) { options.ignoreHiddenFiles = true; options.nonShib = false; options.restartTimes = 3; + options.uplimit = 0; + options.downlimit = 0; ClientProxy clientProxy; parseOptions( app.arguments(), &options ); @@ -478,6 +489,7 @@ restart_sync: SyncEngine engine(account, options.source_dir, folder, &db); engine.setIgnoreHiddenFiles(options.ignoreHiddenFiles); + engine.setNetworkLimits(options.uplimit, options.downlimit); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QObject::connect(&engine, &SyncEngine::finished, [&app](bool result) { app.exit(result ? EXIT_SUCCESS : EXIT_FAILURE); });