2
0
mirror of https://github.com/meganz/MEGAcmd synced 2025-08-22 01:47:24 +00:00

have sync-config display current potentially recalculated values

This commit is contained in:
Pablo Martin 2025-04-02 10:45:52 +02:00
parent 2038da577f
commit 21840cc72a
No known key found for this signature in database
GPG Key ID: 1746978B12F13D6E
3 changed files with 24 additions and 36 deletions

View File

@ -642,8 +642,8 @@ void insertValidParamsPerCommand(set<string> *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"))
{

View File

@ -7850,7 +7850,7 @@ void MegaCmdExecuter::executecommand(vector<string> words, map<string, int> *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<string> words, map<string, int> *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<string> words, map<string, int> *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")

View File

@ -394,6 +394,7 @@ std::optional<Config> makeApiRequest(RequestFunc&& requestFunc)
if (error->getErrorCode() != mega::MegaError::API_OK)
{
setCurrentThreadOutCode(error->getErrorCode());
return std::nullopt;
}