From 58d40c5174d0e76b8e7a8d005d54d724bc70bee3 Mon Sep 17 00:00:00 2001 From: Kleckkinator Date: Wed, 29 Dec 2021 18:19:55 -0600 Subject: [PATCH] Add --operation-timeout argument (#1759) * This change is to create an argument version of the config operation_timeout. There are many times where one may need to temporarily increase the timeout for an operation of a single large file that takes longer than the configured timeout. The command line argument is an excellent way to override the default or 'config' set option if required. --- .gitignore | 1 + config | 3 ++- contrib/completions/complete.bash | 4 ++-- contrib/completions/complete.fish | 1 + contrib/completions/complete.zsh | 1 + onedrive.1.in | 5 +++++ src/config.d | 3 +++ src/onedrive.d | 1 - 8 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index a94ecfed..05e6f9ee 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ config.log config.status autom4te.cache/ contrib/pacman/PKGBUILD +contrib/spec/onedrive.spec diff --git a/config b/config index 6e8de683..ba915d43 100644 --- a/config +++ b/config @@ -47,4 +47,5 @@ # webhook_listening_host = "" # webhook_listening_port = "8888" # webhook_expiration_interval = "86400" -# webhook_renewal_interval = "43200" \ No newline at end of file +# webhook_renewal_interval = "43200" +# operation_timeout = "3600" \ No newline at end of file diff --git a/contrib/completions/complete.bash b/contrib/completions/complete.bash index 2ebe089a..c27a86b1 100644 --- a/contrib/completions/complete.bash +++ b/contrib/completions/complete.bash @@ -13,7 +13,7 @@ _onedrive() prev=${COMP_WORDS[COMP_CWORD-1]} options='--check-for-nomount --check-for-nosync --debug-https --disable-notifications --display-config --display-sync-status --download-only --disable-upload-validation --dry-run --enable-logging --force-http-1.1 --force-http-2 --local-first --logout -m --monitor --no-remote-delete --print-token --resync --skip-dot-files --skip-symlinks --synchronize --upload-only -v --verbose --version -h --help' - argopts='--create-directory --get-O365-drive-id --remove-directory --single-directory --source-directory' + argopts='--create-directory --get-O365-drive-id --operation-timeout --remove-directory --single-directory --source-directory' # Loop on the arguments to manage conflicting options for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do @@ -27,7 +27,7 @@ _onedrive() _filedir return 0 ;; - --create-directory|--get-O365-drive-id|--remove-directory|--single-directory|--source-directory) + --create-directory|--get-O365-drive-id|--operation-timeout|--remove-directory|--single-directory|--source-directory) return 0 ;; *) diff --git a/contrib/completions/complete.fish b/contrib/completions/complete.fish index 5a48447f..a7c99b13 100644 --- a/contrib/completions/complete.fish +++ b/contrib/completions/complete.fish @@ -22,6 +22,7 @@ complete -c onedrive -l local-first -d 'Synchronize from the local directory sou complete -c onedrive -l logout -d 'Logout the current user.' complete -c onedrive -n "not __fish_seen_subcommand_from --synchronize" -a "-m --monitor" -d 'Keep monitoring for local and remote changes.' complete -c onedrive -l no-remote-delete -d 'Do not delete local file deletes from OneDrive when using --upload-only.' +complete -c onedrive -l operation-timeout -d 'Specify the maximum amount of time (in seconds) an operation is allowed to take.' complete -c onedrive -l print-token -d 'Print the access token, useful for debugging.' complete -c onedrive -l remote-directory -d 'Remove a directory on OneDrive - no sync will be performed.' complete -c onedrive -l resync -d 'Forget the last saved state, perform a full sync.' diff --git a/contrib/completions/complete.zsh b/contrib/completions/complete.zsh index be8610ef..e0fd7e40 100644 --- a/contrib/completions/complete.zsh +++ b/contrib/completions/complete.zsh @@ -26,6 +26,7 @@ all_opts=( '--logout[Logout the current user]' '(-m --monitor)'{-m,--monitor}'[Keep monitoring for local and remote changes]' '--no-remote-delete[Do not delete local file deletes from OneDrive when using --upload-only]' + '--operation-timeout[Specify the maximum amount of time (in seconds) an operation is allowed to take.]:seconds:' '--print-token[Print the access token, useful for debugging]' '--resync[Forget the last saved state, perform a full sync]' '--remove-directory[Remove a directory on OneDrive - no sync will be performed.]:directory name:' diff --git a/onedrive.1.in b/onedrive.1.in index 0e24c519..b86b89f7 100644 --- a/onedrive.1.in +++ b/onedrive.1.in @@ -146,6 +146,11 @@ Do not delete local file 'deletes' from OneDrive when using \fB\-\-upload\-only\ .br Configuration file key: \fBno_remote_delete\fP (default: \fBfalse\fP) .TP +\fB\-\-operation\-timeout\fP ARG +Set the maximum amount of time (seconds) a file operation is allowed to take. This includes DNS resolution, connecting, data transfer, etc. +.br +Configuration file key: \fBoperation_timeout\fP (default: \fB3600\fP) +.TP \fB\-\-print\-token\fP Print the access token, useful for debugging .TP diff --git a/src/config.d b/src/config.d index 40d51527..fd0b7419 100644 --- a/src/config.d +++ b/src/config.d @@ -400,6 +400,9 @@ final class Config "no-remote-delete", "Do not delete local file 'deletes' from OneDrive when using --upload-only", &boolValues["no_remote_delete"], + "operation-timeout", + "Maximum amount of time (in seconds) an operation is allowed to take", + &longValues["operation_timeout"], "print-token", "Print the access token, useful for debugging", &boolValues["print_token"], diff --git a/src/onedrive.d b/src/onedrive.d index b5cee70d..9adf5191 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -230,7 +230,6 @@ final class OneDriveApi // maximum time an operation is allowed to take // This includes dns resolution, connecting, data transfer, etc. http.operationTimeout = (dur!"seconds"(cfg.getValueLong("operation_timeout"))); - // Specify how many redirects should be allowed http.maxRedirects(5);