Commit Graph
2150 Commits
Author SHA1 Message Date
Nick Craig-Wood 2a13b4ee0a operations: speed up multi-thread uploads from local disk by reading 1 MiB blocks
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.
2026-11-22 17:44:55 +00:00
FTCHD 5ad00fc4bd docs: fix typos and grammar mistakes in help text 2026-11-22 17:11:32 +00:00
Nick Craig-Wood 14dc9c5dba fs: log an error if a backend saves config which has no config option
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.
2026-11-21 11:30:22 +00:00
FTCHD a16cfc97ba fs: fix secrets appearing in the debug log
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
2026-11-21 11:29:49 +00:00
Mohammed Numaan 4d0869df6e config: fix data race when concurrent calls first load the config - fixes #10119 2026-11-19 17:04:45 +00:00
Mradul Singh a6779f3d79 operations: fix --name-transform applied twice on update - fixes #10332
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.
2026-11-18 11:28:54 +00:00
Navid Khan (Ali) 9fa8061fec accounting: fix data race in StatsInfo.RemoteStats - fixes #10329
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.
2026-11-18 11:23:51 +00:00
Nick Craig-Wood eccd97d75a fs: fix wrapping backends doing an extra transaction per file on s3, swift and ftp
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.
2026-11-17 16:48:10 +00:00
Nick Craig-Wood c5e537e3aa fs: fix wrapping backends allowing multi-thread downloads the backend forbids
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.
2026-11-17 16:48:10 +00:00
Nick Craig-Wood 3f8764db81 rc: refuse inline remotes and connection string parameters in --rc-serve URLs
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.
2026-11-17 16:48:10 +00:00
nielash 64c536e441 rc: add long parameter to config/listremotes to return remote types
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.
2026-11-11 16:20:38 +00:00
Huang-404-Q 4cf147ab08 operations: fix dropping objects without an ID in dedupe
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).
2026-11-11 16:08:40 +00:00
albertony ba96467b69 operations: normalize paths in SUM files
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.
2026-11-11 10:36:07 +00:00
albertony c1258b0494 operations: support escaped file names in SUM files 2026-11-11 10:36:07 +00:00
albertony 380979edc6 operations: fix SUM file lines longer than 4096 bytes 2026-11-11 10:36:07 +00:00
albertony 5ed5d9586b operations: support non-MD5 SUM files from FSUM
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.
2026-11-11 10:36:07 +00:00
albertony 5af030df0a operations: ignore comment lines in SUM files 2026-11-11 10:36:07 +00:00
albertony d4bf998f7b operations: support SUM files with a byte order mark 2026-11-11 10:36:07 +00:00
berce cdad8ce1f3 config: keep a token passed to config create/update
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
2026-11-11 10:21:04 +00:00
Navid Khan (Ali) 41893f019f fs: allow SizeSuffix MaxInt64 itself to round-trip 2026-11-11 10:16:31 +00:00
Navid Khan (Ali) 95487b2ff9 fs: make SizeSuffix serialisation round-trip exactly - fixes #10205 2026-11-11 10:16:31 +00:00
Nick Craig-Wood 82cb84b201 Start v1.77.0-DEV development 2026-11-06 16:31:22 +00:00
Nick Craig-Wood 53b2d7aaf2 rc: reject unauthorised and unknown calls before reading the request GHSA-f8p4-8g4j-q3m2 CVE-PENDING
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.
2026-11-06 12:08:10 +00:00
Nick Craig-Wood 17ebd339da rc: limit request size when the rc server has no authentication GHSA-f8p4-8g4j-q3m2 CVE-PENDING
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.
2026-11-06 12:08:10 +00:00
Nick Craig-Wood b4659519df fshttp: refuse HTTPS to HTTP redirects unless --allow-https-downgrade GHSA-m97j-7x65-wh93 CVE-PENDING
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.
2026-11-06 12:08:09 +00:00
Seth WestphalandClaude Opus 5.5 bbf4a983d7 fs: add MIME type for JPEG XL (.jxl) files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 12:32:14 +00:00
唐僧洗发用飘柔 3ca4fd99b6 operations: fix oversized getfile tail requests
Clamp suffix ranges that extend past the start of the file before checking the maximum response size.

Fixes #9941
2026-11-05 12:21:26 +00:00
Nick Craig-Wood c9a5f106a4 test_all: run the 50 byte chunker tests against Minio instead of AWS S3
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.
2026-11-03 15:40:03 +00:00
b84330808andClaude Opus 5.5 4e19a969f5 operations: fix cat --offset before the start of a file printing its end
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>
2026-10-31 15:29:07 +00:00
Soujas K a89766467e fs: reject NaN durations instead of wrapping
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.
2026-10-31 15:18:08 +00:00
ilya lavrenov b44c24cfca accounting: fix totalBytes counting server-side copies and moves twice
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.
2026-10-31 13:17:30 +00:00
kevin9327 64a68c7380 fs: reject --bwlimit times without a colon or with signed digits
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.
2026-10-31 12:36:13 +00:00
kevin9327 18c7de0920 fs: reject NaN sizes and CountSuffix values that overflow
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.
2026-10-31 12:27:06 +00:00
kevin9327 0de32e2269 filter: make [^...] in globs exclude / and document it
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.
2026-10-31 12:26:02 +00:00
kevin9327 c434df94d1 filter: make [!...] in globs a negated character class
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.
2026-10-31 12:26:02 +00:00
kevin dee8b7e285 fs: accept multi-unit relative times like 1d12h in Time options
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.
2026-10-31 12:24:46 +00:00
Nick Craig-Wood 611416b140 operations: fix TestMoveOntoItself on eventually consistent backends
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.
2026-10-27 17:24:14 +00:00
Dirk Petersen a7759387d6 hash: add CRC-32C (Castagnoli) support
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).
2026-10-27 14:40:02 +00:00
nielash ea465cbb97 operations: skip the Unicode move test where NFD names aren't kept
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.
2026-10-26 17:41:06 +00:00
nielash 9f1d0cf021 operations: fix moving a file onto its own name deleting 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.
2026-10-26 17:41:06 +00:00
kevin9327 40139a749e fs: reject durations like 300y that overflow instead of wrapping
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.
2026-10-20 10:49:46 +01:00
nielash a22df73dec operations: fix case- or Unicode-only renames deleting the 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.
2026-10-18 17:24:30 +01:00
Nick Craig-Wood 7436d05e36 list: fix ext sort error sometimes being ignored at the end of a listing
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.
2026-10-17 15:48:14 +01:00
Nick Craig-Wood 3ae50732b5 list: fix TestSorterExtTempFileError with lanrat/extsort v1.5.0
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.
2026-10-17 15:48:14 +01:00
Cao Yuhang 36febacabd operations: respect backup-dir in deletefile 2026-10-15 16:31:37 +01:00
ghwany cf7cdbc49f sync: fix --delete-empty-src-dirs disabled by a prior error in a reused stats group - fixes #9634
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().
2026-10-14 17:52:31 +01:00
kaii9 af364f5468 filter: speed up large --include-from lists of directories - fixes #9014 2026-10-14 12:05:05 +01:00
Nick Craig-Wood a96a8b7757 rc: fix LogLevel in _config being ignored
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.
2026-10-14 09:38:25 +01:00
Nick Craig-Wood 896ea32789 operations, sync, march, walk, list, filter: attribute logs to the rc job
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.
2026-10-14 09:38:25 +01:00
Nick Craig-Wood 8c5a60f31d fs: add context aware log functions so logs can be attributed
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.
2026-10-14 09:38:25 +01:00