mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 05:15:40 +03:00
owncloudcmd: add --max-sync-retries #4037
And limit by default to 3 retries
This commit is contained in:
parent
0c467ef5b4
commit
16c078963b
1 changed files with 12 additions and 2 deletions
|
@ -58,6 +58,7 @@ struct CmdOptions {
|
|||
bool ignoreHiddenFiles;
|
||||
QString exclude;
|
||||
QString unsyncedfolders;
|
||||
int restartTimes;
|
||||
};
|
||||
|
||||
// we can't use csync_set_userdata because the SyncEngine sets it already.
|
||||
|
@ -155,6 +156,7 @@ void help()
|
|||
std::cout << " --password, -p [pass] Use [pass] as password" << 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 << " --max-sync-retries [n] Retries maximum n times (default to 3)" << 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;
|
||||
|
@ -222,6 +224,8 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
|
|||
options->exclude = it.next();
|
||||
} else if( option == "--unsyncedfolders" && !it.peekNext().startsWith("-") ) {
|
||||
options->unsyncedfolders = it.next();
|
||||
} else if( option == "--max-sync-retries" && !it.peekNext().startsWith("-") ) {
|
||||
options->restartTimes = it.next().toInt();
|
||||
} else {
|
||||
help();
|
||||
}
|
||||
|
@ -268,6 +272,7 @@ int main(int argc, char **argv) {
|
|||
options.useNetrc = false;
|
||||
options.interactive = true;
|
||||
options.ignoreHiddenFiles = true;
|
||||
options.restartTimes = 3;
|
||||
ClientProxy clientProxy;
|
||||
|
||||
parseOptions( app.arguments(), &options );
|
||||
|
@ -356,6 +361,7 @@ int main(int argc, char **argv) {
|
|||
account->setCredentials(cred);
|
||||
account->setSslErrorHandler(sslErrorHandler);
|
||||
|
||||
int restartCount = 0;
|
||||
restart_sync:
|
||||
|
||||
CSYNC *_csync_ctx;
|
||||
|
@ -458,8 +464,12 @@ restart_sync:
|
|||
csync_destroy(_csync_ctx);
|
||||
|
||||
if (engine.isAnotherSyncNeeded()) {
|
||||
qDebug() << "Restarting Sync, because another sync is needed";
|
||||
goto restart_sync;
|
||||
if (restartCount < options.restartTimes) {
|
||||
restartCount++;
|
||||
qDebug() << "Restarting Sync, because another sync is needed" << restartCount;
|
||||
goto restart_sync;
|
||||
}
|
||||
qWarning() << "Another sync is needed, but not done because restart count is exceeded" << restartCount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue