Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added owncloudcmd bwlimit #5707

Merged
merged 3 commits into from
Apr 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/cmd/cmd.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright (C) by Olivier Goffart <[email protected]>
* Copyright (C) by Klaas Freitag <[email protected]>
* Copyright (C) by Daniel Heule <[email protected]>
*
* 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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -478,6 +489,7 @@ int main(int argc, char **argv) {

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); });
Expand Down