diff --git a/src/megacmd.cpp b/src/megacmd.cpp index f75b59e0..a6369d75 100644 --- a/src/megacmd.cpp +++ b/src/megacmd.cpp @@ -642,8 +642,8 @@ void insertValidParamsPerCommand(set *validParams, string thecommand, se } else if ("sync-config" == thecommand) { - validOptValues->insert("delayed-uploads-wait-seconds"); - validOptValues->insert("delayed-uploads-max-attempts"); + validParams->insert("delayed-uploads-wait-seconds"); + validParams->insert("delayed-uploads-max-attempts"); } else if ("export" == thecommand) { @@ -1792,7 +1792,7 @@ const char * getUsageStr(const char *command, const HelpFlags& flags) } if (!strcmp(command, "sync-config")) { - return "sync-config [--delayed-uploads-wait-seconds=waitsecs | --delayed-uploads-max-attempts=attempts]"; + return "sync-config [--delayed-uploads-wait-seconds | --delayed-uploads-max-attempts]"; } if (!strcmp(command, "backup")) { @@ -2595,7 +2595,7 @@ string getHelpStr(const char *command, const HelpFlags& flags = {}) os << "If local and remote paths are provided, it will start synchronizing a local folder into a remote folder." << endl; os << "If an ID/local path is provided, it will list such synchronization unless an option is specified." << endl; os << endl; - os << "Note: use the \"sync-config\" command to show and modify global sync configuration." << endl; + os << "Note: use the \"sync-config\" command to show global sync configuration." << endl; os << endl; os << "Options:" << endl; os << " -d | --delete" << " " << "ID|localpath" << "\t" << "deletes a synchronization (not the files)." << endl; @@ -2708,25 +2708,15 @@ string getHelpStr(const char *command, const HelpFlags& flags = {}) } else if (!strcmp(command, "sync-config")) { - auto duLimits = GlobalSyncConfig::DelayedUploads::getCurrentLimits(*api); - - os << "Shows and modifies global sync configuration." << endl; + os << "Controls sync configuration." << endl; os << endl; - os << "Displays current configuration if no options are provided. Configuration values are persisted across restarts." << endl; + os << "Displays current configuration." << endl; os << endl; - os << "New uploads for files that change frequently in syncs will be delayed until a wait time passes." << endl; + os << "New uploads for files that change frequently in syncs may be delayed until a wait time passes to avoid wastes of computational resources." << endl; + os << " Delay times and number of changes may change overtime" << endl; os << "Options:" << endl; - os << " --delayed-uploads-wait-seconds Sets the seconds to be waited before a file that's being delayed is uploaded again. Default is 30 minutes (1800 seconds)." << endl; - if (duLimits) - { - os << " Note: wait seconds must be between " << duLimits->mLower.mWaitSecs << " and " << duLimits->mUpper.mWaitSecs << " (inclusive)." << endl; - } - - os << " --delayed-uploads-max-attempts Sets the max number of times a file can change in quick succession before it starts to get delayed. Default is 2." << endl; - if (duLimits) - { - os << " Note: max attempts must be between " << duLimits->mLower.mMaxAttempts << " and " << duLimits->mUpper.mMaxAttempts << " (inclusive)." << endl; - } + os << " --delayed-uploads-wait-seconds Shows the seconds to be waited before a file that's being delayed is uploaded again." << endl; + os << " --delayed-uploads-max-attempts Shows the max number of times a file can change in quick succession before it starts to get delayed." << endl; } else if (!strcmp(command, "backup")) { diff --git a/src/megacmdexecuter.cpp b/src/megacmdexecuter.cpp index 363b451f..c63b4e6b 100644 --- a/src/megacmdexecuter.cpp +++ b/src/megacmdexecuter.cpp @@ -7850,7 +7850,7 @@ void MegaCmdExecuter::executecommand(vector words, map *clf { OUTSTREAM << endl; OUTSTREAM << "Some of your \"Pending\" sync uploads are being delayed due to very frequent changes. They will be uploaded once the delay finishes. " - << "Use the \"" << getCommandPrefixBasedOnMode() << "sync-config\" command to configure the upload delay." << endl; + << "Use the \"" << getCommandPrefixBasedOnMode() << "sync-config\" command to show the upload delay." << endl; } } else @@ -7956,10 +7956,11 @@ void MegaCmdExecuter::executecommand(vector words, map *clf return; } - auto duWaitSecsOpt = getIntOptional(*cloptions, "delayed-uploads-wait-seconds"); - auto duMaxAttemptsOpt = getIntOptional(*cloptions, "delayed-uploads-max-attempts"); + auto duWaitSecsOpt = getFlag(clflags, "delayed-uploads-wait-seconds"); + auto duMaxAttemptsOpt = getFlag(clflags, "delayed-uploads-max-attempts"); + + bool all = !duWaitSecsOpt && !duMaxAttemptsOpt; - if (!duWaitSecsOpt && !duMaxAttemptsOpt) { auto duConfigOpt = DelayedUploads::getCurrentConfig(*api); if (!duConfigOpt) @@ -7969,20 +7970,16 @@ void MegaCmdExecuter::executecommand(vector words, map *clf } DelayedUploads::Config duConfig = *duConfigOpt; - OUTSTREAM << "Delayed uploads wait time: " << duConfig.mWaitSecs << " seconds" << endl; - OUTSTREAM << "Max attempts until uploads are delayed: " << duConfig.mMaxAttempts << endl; + if (all || duWaitSecsOpt) + { + OUTSTREAM << "Delayed uploads wait time: " << duConfig.mWaitSecs << " seconds" << endl; + } + if (all || duMaxAttemptsOpt) + { + OUTSTREAM << "Max attempts until uploads are delayed: " << duConfig.mMaxAttempts << endl; + } return; } - - if (duWaitSecsOpt) - { - DelayedUploads::updateWaitSecs(*api, *duWaitSecsOpt); - } - - if (duMaxAttemptsOpt) - { - DelayedUploads::updateMaxAttempts(*api, *duMaxAttemptsOpt); - } } #endif else if (words[0] == "cancel") diff --git a/src/sync_command.cpp b/src/sync_command.cpp index bd389e53..b5ea7d88 100644 --- a/src/sync_command.cpp +++ b/src/sync_command.cpp @@ -394,6 +394,7 @@ std::optional makeApiRequest(RequestFunc&& requestFunc) if (error->getErrorCode() != mega::MegaError::API_OK) { + setCurrentThreadOutCode(error->getErrorCode()); return std::nullopt; }