Multi-thread copies from a local source hand the chunk writer an
unbuffered ReOpen. Backends such as s3, azureblob and
oracleobjectstorage checksum the chunk with io.Copy before uploading
it, and as ReOpen didn't implement io.WriterTo, io.Copy read the file
in 32 KiB pieces.
ReOpen now implements io.WriterTo:
- If the destination implements io.ReaderFrom, that is used so the
destination's own buffering is kept. This means multi-thread
downloads (bufio.Writer over an OffsetWriter, sized by
--multi-thread-write-buffer-size) and HTTP request bodies behave as
before and don't gain an extra buffer.
- If less than 1 MiB remains it uses io.Copy as before, so small files
don't take a 1 MiB buffer.
- Otherwise it copies through a 1 MiB buffer from the global pool, so
the memory is reused and is counted by --max-buffer-memory.
This replaces the s3 specific io.CopyBuffer from a68480093 (reverted
in the previous commit) which allocated a fresh 1 MiB buffer for every
chunk outside of --max-buffer-memory, and gives the same speedup to
every backend which io.Copies from the chunk reader.
Benchmarks on Linux, 16 cores, source file on tmpfs, warm cache.
"orig" is master with a68480093 reverted (32 KiB reads), "master" has
a68480093 (make 1 MiB per chunk), "branch" is this commit.
Checksum pass only - ReOpen of a local 128 MiB range into md5, 5 runs:
1 stream MB/s B/op
orig 752-759 34 KiB
master 751-784 1025 KiB
branch 764-784 1.2 KiB
16 streams MB/s B/op
orig 4772-5495 547 KiB
master 4008-4607 16405 KiB
branch 4525-5052 22 KiB
On Linux the reads are cheap so the larger reads are worth ~2-3% for
a single stream and are lost in the noise with 16 streams. The point
here is that branch matches master's reads without allocating.
The same benchmark on Windows 10 (VirtualBox VM, 8 vCPUs on a Ryzen 7
PRO 5850U, 64 MiB chunk per stream, 1 GiB file in the file cache),
where reads are more expensive, shows the speedup. Median of 5 runs:
streams orig master branch
1 560 MB/s 594 MB/s (+6.1%) 610 MB/s (+9.0%)
4 1438 MB/s 1594 MB/s (+10.9%) 1610 MB/s (+12.0%)
8 1878 MB/s 2123 MB/s (+13.0%) 2143 MB/s (+14.1%)
allocated per op (all streams)
1 33 KiB 1026 KiB 1 KiB
4 134 KiB 4102 KiB 5 KiB
8 267 KiB 8204 KiB 10 KiB
With 4 and 8 streams the ranges of orig and branch don't overlap.
End to end - rclone copy of a 2 GiB local file to MinIO on localhost
(server bound, so wall time doesn't change), mean of 4 runs, max RSS
and number of GCs from GODEBUG=gctrace=1:
default (5 MiB chunks, 4 streams)
wall max RSS GCs
orig 6.13s 84 MiB 14
master 6.29s 93 MiB 54
branch 6.30s 90 MiB 8
--s3-upload-concurrency 16 --s3-chunk-size 64M
wall max RSS GCs
orig 4.76s 83 MiB 6
master 4.80s 112 MiB 7
branch 4.80s 97 MiB 6
Multi-thread download of the same file from MinIO to local disk
(checks the io.ReaderFrom path), mean of 4 runs:
wall max RSS GCs
orig 4.31s 80 MiB 5
master 4.31s 80 MiB 5
branch 4.32s 80 MiB 5
Uploads with --max-buffer-memory 2M and 4M (with
--s3-upload-concurrency 16 --s3-chunk-size 64M) complete normally in
5-7s, throttled rather than stalled.
Config saved by a backend with no matching config option isn't
redacted by rclone config redacted, and can't be set with flags or
environment variables.
This logs an internal error when that happens and panics when running
tests so these are caught by the integration tests.
Keys supplied by the user with rclone config create and update are
still saved without checking.
redact these values in the debug log:
- password and sensitive flags set from environment variables, also
in the error for an invalid value
- the client secret from jottacloud config
- the token after a bad token response from shade
- the login_token used to open the rc web gui
When copy, sync or move found an existing destination file, Copy and
move replaced the transformed source name with a transform of the
destination's name. That name is already transformed (it is how the
file was matched), so updates went to a doubly transformed name, e.g.
prefix-prefix-file.txt instead of prefix-file.txt.
Keep the transformed source name when --name-transform is in use and
only fall back to the destination's name when it isn't, which keeps
the existing case of a file on case-insensitive remotes as before.
TransformFile and convmv are unaffected as their dst is the source
file itself.
RemoteStats read s.errors and s.lastError after releasing s.mu,
while Error writes both fields under the write lock, so polling
stats concurrently with a failing transfer raced. Move the
lastError read inside the existing read-lock section and guard
against a nil lastError, which Errors() can leave behind when it
bumps the error count on its own. Adds a regression test that
runs concurrent Error and RemoteStats calls under the race
detector.
Features.Mask combined SlowModTime with AND, but it is a restriction.
Wrapping backends such as crypt start with it false, so crypt over s3,
swift, qingstor, oracleobjectstorage or ftp lost it and read the
modtime when a fast fingerprint was wanted. This cost an extra
transaction per file when downloading through crypt to local, and with
--vfs-fast-fingerprint. Combine it with OR so the restriction
propagates through Mask.
Note that this changes the fast fingerprint for these wrapped remotes,
so a VFS cache using --vfs-fast-fingerprint will treat its cached
files as changed once after upgrading.
Features.Mask combined NoMultiThreading with AND like the positive
feature flags, but it is a restriction. Wrapping backends such as
crypt, chunker, compress, hasher, union and combine start with it
false, so they dropped it and crypt over pikpak or protondrive used
multi-thread downloads. Combine it with OR so the restriction
propagates through Mask.
With --rc-serve a GET of a URL such as /[:sftp,ssh=cmd:]/ instantiated
the inline remote, which runs a command, provided the rc had
authentication configured or --rc-no-auth was in use.
A web page can make a browser send such a GET with an <img> tag, and
the browser will add any credentials it has cached for the rc.
Browsers only mark these requests as cross-origin when they are sent to
localhost or over HTTPS, so for an rc server on another address rclone
could not tell the request came from a web page.
Inline remotes and connection string parameters in --rc-serve URLs are
now always refused. Remotes in the config file can still be served,
as can bare local paths if authentication is configured or
--rc-no-auth is in use.
The exception is [:local:/path] without parameters, which is the same
as the bare local path [/path] and is treated as one. rclone-ui uses
this form to preview local files.
This changes the rule introduced for CVE-2026-49980 where
authentication or --rc-no-auth allowed everything on the serve path.
Before this change, rc `config/listremotes` returned only the names of
the remotes, so a client that needed each remote's type (such as a GUI)
had to call `config/dump` and read the whole config. That also missed
the type of remotes defined only by environment variables.
After this change, `config/listremotes` takes an optional `long`
parameter. When it is true, `remotes` is an array of objects with the
`name`, `type`, `source` and `description` of each remote, the same
as `rclone listremotes --long --json` outputs. Without it, the output is
unchanged.
Before this change, dedupeDeleteIdentical dropped every object which
didn't implement fs.IDer or whose ID was empty. This emptied the list
of duplicates, so Deduplicate logged "All duplicates removed" and did
nothing on duplicate-capable backends without object IDs (e.g. ulozto,
or crypt and chunker wrapping such a backend).
Paths like "./dir/file", as from find, and "/dir/file" were not matched,
and on Windows backslash was not accepted as path separator, as written
by Windows tools.
FSUM marks hashes other than MD5 with the algorithm, as in
"<hash> ?SHA1*<file>", and writes one line per algorithm per file.
Use marked lines only for the requested hash type, and prefer them to
unmarked lines.
A token passed to config update was stored and then the oauth post
config asked config_refresh_token about it, which interactively
started the browser flow to replace it. Answer config_refresh_token
with false when a token is passed and the caller didn't answer it.
Fixes#10208
The rc server decoded the whole POST body before looking up the method
and checking whether it needed authorisation, then echoed the decoded
input back in the 403 or 404 error. A client that was not allowed to
call a method could still make rclone read, decode and re-encode its
request.
The method lookup and authorisation check now happen before the body
is read, and these errors no longer echo the request input.
When the rc server was running without HTTP authentication and without
--rc-no-auth, anyone able to connect to it could POST an arbitrarily
large body to any rc path. A JSON body was decoded in full and then
echoed back in the response, so a single large request could make
rclone use several times the body size in memory and be killed by the
OOM killer.
In this mode only the small set of NoAuth methods can be called, so
POST bodies are now limited to 64 KiB and oversized requests are
rejected with 413 Request Entity Too Large without echoing the input.
Servers with authentication or --rc-no-auth are unaffected.
A server which redirects an https:// request to an http:// URL makes
rclone replay the request in cleartext. Any credentials the backend
sets as headers are then readable by anyone on the network path, and
the response can be altered in transit.
The transport now refuses to follow such a redirect, so this holds for
every client built on it, including those of libraries which install
their own redirect policy. Use --allow-https-downgrade to follow the
redirect anyway, for example when downloading from a mirror which
redirects to plain HTTP.
Backends which check redirects themselves still refuse a downgrade
which would send their credentials in cleartext, regardless of the
flag.
The 5 chunker remotes with 50 byte chunks split each test file into
many objects which made them expensive to run against AWS S3. Run
them against the TestS3Minio docker server instead and keep
TestChunkerS3 with the default chunk size on AWS.
When a negative --offset reached back past the start of a file and
--count was set, rclone cat printed bytes from the end of the file
instead of from its start. For example on a 10 byte file
rclone cat --offset -12 --count 5 file
printed the last 2 bytes rather than the first 5. With several files
of different sizes, each file shorter than -offset was affected.
The start of the range stayed negative after the file size was added,
and a negative Start with an End set is a suffix range (the last End
bytes). Clamp the start to 0 instead, which matches what
`tail -c 12 file | head -c 5` prints. --tail and --offset without
--count were not affected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
strconv.ParseFloat accepts "NaN", and NaN compares false with every
bound, so it got past the overflow check added for 300y and was then
converted to a time.Duration, which gives the minimum int64 on amd64.
--max-age NaN or --min-age NaNM silently became about -292 years,
which moves the filter's ModTimeFrom into the future and excludes every
file, instead of being rejected.
When a server-side copy or move finished without reporting progress
along the way, its bytes were added to the stats but not to the
transfer, so until the transfer ended core/stats reported totalBytes as
the bytes done plus the whole size of the transfer still in progress.
A 1 GiB server-side copy on the local backend showed 1 GiB of 2 GiB
while rclone checked the hashes.
The bytes now go on the transfer as well, as they already did for
backends which report progress through NewServerSideCopyAccounter.
validateHour only checked the length of the hh:mm field and then
parsed the two halves with strconv.Atoi. It never checked the third
character, so "10h20" or "Mon-10.20" were accepted as 10:20, and
since Atoi accepts a sign, "+1:00" and "Mon-10:+5" were accepted
as 01:00 and 10:05.
Require the colon and four digits so these are reported as invalid
time specifications like other malformed times.
SizeSuffix.Set and CountSuffix.Set accepted "nan" before a suffix, so
--max-transfer nank became -1 ("off") without an error. CountSuffix.Set
also had no overflow check, unlike SizeSuffix, so 10E or infk wrapped
to the same value.
A glob like file[^a].txt was translated to (^|/)file[^a]\.txt$ in path
mode, so it matched file/.txt across a directory boundary, unlike ?
and the [!...] form.
Treat a leading ^ in a character class the same as a leading !: in
path mode it now also excludes /, and [^] is rejected as an empty
character class. Document both negation forms in the filtering
grammar.
The filtering docs give the character class syntax as [ [ ! ]
{ character-range } ], but globToRegexp copied the ! into the regexp
unchanged, so file[!a].txt matched filea.txt and file!.txt and
excluded fileb.txt - the opposite of what was asked for.
Translate a ! at the start of a character class to ^. In path mode
the class also excludes /, in the same way ? does. [!] is rejected
as an empty character class.
The docs say Time options take the same relative forms as Duration
options, with "1d12h" as an example, but ParseTime only tried
time.ParseDuration and single-suffix values, so --max-age style
Time options such as --s3-version-at 1d12h were rejected.
The test looked up the object it had just uploaded without retrying, so
it failed with "object not found" on backends such as Cloudinary and
Internxt where new objects take a moment to appear.
Add the hash type crc32c. It is the checksum that AWS S3 stores for
objects uploaded with x-amz-checksum-crc32c (FULL_OBJECT checksum),
and the checksum that iSCSI, ext4 and Btrfs use. Go calculates it with
the SSE 4.2 and ARMv8 CRC32 instructions where they are available.
With it, rclone can calculate the value that S3 returns in
ChecksumCRC32C for a local file:
rclone hashsum crc32c file
prints it as hex; `--base64` prints it in the URL-safe base64 alphabet
that rclone uses for every hash (`-` and `_` where S3 prints `+` and
`/`).
The new type is registered after the existing core types, so their
Type values do not change. The types that backends register (dropbox,
hidrive, mailru, quickxor) move up one bit, as they did when blake3,
xxh3 and xxh128 were added; no Type value is persisted (the hasher
cache and bisync listings store hash names).
Before this change, `TestMoveUnicodeEquivalentWithoutServerSideMove`
failed on backends that can't store a file under the NFD name it was given:
`mailru` rejects the name ("invalid characters in object name"), and
`cloudinary`, `filelu` and `seafile` don't find the file again under it.
Tests in `fs/operations` run against every backend, so this one needs to
skip where the precondition doesn't hold.
After this change, the test skips when the NFD name can't be uploaded or
the file isn't found again under it.
Before this change, `operations.Move` and `operations.MoveTransfer`
deleted a file when asked to move it onto its own path without a `dst`
object. Without server-side `Move`, `operations.move` copied the file onto
itself and then deleted the source, which was the same file, and the
`memory` backend's server-side `Move` did the same. `storj` stores every
name in NFC, so there a move from a file's NFD name to its NFC name is a
move onto its own path, and `TestMoveUnicodeEquivalentWithoutServerSideMove`
lost the file on `TestStorj`.
After this change, a move whose destination is the file's own path on the
same remote does nothing, including when the destination `Fs` has a
different root.
ParseDuration checked for overflow in multi-unit durations such as
300y1d but not in single-suffix ones, so --max-age 300y silently
became a large negative duration, which moved the filter's
ModTimeFrom into the future and excluded every file.
Before this change, on backends without server-side `Move`, renaming a
file to an equivalent name deleted it: a name differing only in case on
a case-insensitive backend, or only in Unicode normalization on a
backend such as Cloudflare R2, which treats NFC and NFD names as
equivalent. `operations.move` fell back to copying the file to the new
name and then deleting the source, but both resolved to the same object,
so the delete removed the file it just copied. This affected
`--fix-case` renames in `sync` and `bisync`, `--track-renames` with
`--no-unicode-normalization`, and renames through the VFS
(`rclone mount`, `rclone serve`). `MoveFile` and backends with
server-side `Move` already handled these renames by moving through a
temporary name.
After this change, the copy-and-delete fallback also moves through a
temporary name when the two names are equivalent. The issue was discovered on
the bisync integration tests.
Sorter.Send selects on both the output and error channels of the ext
sort. If the ext sort failed it closes both, so the select could pick
the closed output channel and return without the error. This was seen
as a flaky TestSorterExtTempFileError under the race detector.
extsort now only creates temp files when the data doesn't fit in
one chunk, so the test needs to add more than a chunk of entries to
provoke the temp file error.
deleteEmptyDirectories gated on the cumulative accounting stats
(accounting.Stats(ctx).Errored()) instead of the current operation's error.
On a long-running rcd that reuses one stats group (rc "_group") across many
sync/move calls, a single earlier error left Errored() true forever, which
permanently disabled empty-source-directory deletion for every later,
error-free operation sharing the group - each run just logged "not deleting
directories as there were IO errors" and never cleaned up.
Gate on s.currentError() instead, so empty-directory cleanup depends only on
the current operation's outcome. This matches the per-operation guards already
used elsewhere in run(), and is a no-op for normal single runs where
Errored() (s.errors != 0) tracks the same errors that reach s.currentError().
Before this change setting LogLevel in the _config parameter of an rc
call had no effect as both the log functions and the log handler only
looked at the global log level.
The context aware log functions now use the log level from the config
in the context, and the log handler lets a log level in the context
which differs from the global one override its own level. This means
an rc call can be made more or less verbose than the rest of rclone
with, for example
"_config": {"LogLevel": "DEBUG"}
This applies to the logs made with the context aware log functions, so
not to those made by the backends which still use the global log level.
Note that a config copied into a context no longer follows later
changes to the global log level.
Use the context aware log functions throughout the code which runs
sync, copy, move, check and the other operations, and the directory
listings they do, so that the logs they make, such as the per file
"Copied (new)" logs, are attributed to the rc job and stats group of
the operation.
This adds ErrorfCtx, LogfCtx, InfofCtx, DebugfCtx and LogPrintfCtx
which take a context and pass it on to the log handler. The handler
can then attribute the log to what made it using the new
StatsGroupFromContext and JobIDFromContext function pointers, which
fs/accounting and fs/rc/jobs fill in.
The format string is no longer assigned to in logPrintf so that go
vet recognises these as printf wrappers and checks the arguments of
their callers.