Repository navigation
Conversation
Options passed flat at the top level of an rc call were turned into a
string and parsed like a command line flag, so a number meant KiB for a
size and seconds for a duration. The nested form and the rc docs read a
number as bytes and nanoseconds, so the documented example
"buffer_size": 44040192
set a 42 GiB buffer rather than 42 MiB. Integers of a million or more
also came out as "1e+06" and were rejected by int options.
Decode numbers as JSON so they mean the same as in the nested form.
Strings are parsed as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change do?
The rc docs say a size can be passed flat as a number of bytes:
but the second form sets a 42 GiB buffer.
configstruct.SetAnyturns every flat value into a string and parses it like a command line flag, so a number is read as KiB for a size and as seconds for a duration. The nested_config/vfsOptform goes throughUnmarshalJSONand reads the same numbers as bytes and nanoseconds, which is what the data types section describes.Plain int options were affected too: integers of a million or more come out of
fmt.Sprintas1e+06and fail to parse.This decodes numbers as JSON into the field's type, so flat and nested values mean the same thing. Strings still go through the command line parser, so
rclone rc ... buffer_size=42M timeout=30sbehaves exactly as before, and a number that doesn't decode falls back to the old path.One behaviour change to be aware of: a duration passed flat as a number was seconds and is now nanoseconds, matching
_configand the docs."timeout": "30s"is unaffected.Side note:
setIfSameTypecan't match when called fromSetAny, since it compares against the type of theanyvariable rather than the value inside it. I haven't touched it here.Tests: new
TestParseOptions/FlatNumberssubtest. On master it fails withSize:45097156608,Duration:5000000000000000000andparsing "1e+06" as int failed.make quicktestmatches master (cmd/gitannexfails on both, nogit-annexhere), andgolangci-lint runon the changed packages reports 0 issues.Linked issue
None, the docs already describe the intended behaviour.
Checklist