Skip to content

compress: fix default level hanging zstd and disabling gzip compression - #10230

Merged
ncw merged 2 commits into
rclone:masterfrom
akasakariko:compress-fix-default-level
Nov 11, 2026
Merged

ncw merged 2 commits into
rclone:masterfrom
akasakariko:compress-fix-default-level

Conversation

@akasakariko

Copy link
Copy Markdown
Contributor

What is the purpose of this change?

Since zstd support was added in #8756 the level option lost its default and
was marked required. When no level is configured it stayed at its zero value,
which broke both modes:

  • gzip: level 0 means "no compression", so compressible files were
    uploaded as valid but uncompressed .gz files.
  • zstd: 0 is not a valid encoder level. klauspost/compress rejects it,
    and the error path in putCompress never closed the pipe used to stream the
    compressed data, so rclone copyto hung forever waiting for EOF.

This restores the -1 default. Since the option is shared by both modes, -1
is translated to zstd's default level (2), while gzip passes it straight
through to sgzip as before. The documented zstd level 0 ("turns off
compression") is now implemented by storing the file uncompressed, and
out-of-range levels are rejected when the Fs is created with a clear error
instead of hanging mid-transfer.

The compression goroutines now close the pipe with the encoder error and the
result channels are buffered, so a failing encoder or upload can no longer
leave the transfer blocked.

Testing

go test ./backend/compress and go vet ./backend/compress/ pass, including
new tests for the gzip/zstd defaults, zstd level 0, and invalid levels.

Manual check with the 36,492-byte file from the issue:

case before after
gzip, default level 36,522-byte uncompressed .gz 937-byte .gz
zstd, default level hangs 747-byte .zst
zstd, level 0 hangs uncompressed .bin
gzip/zstd, invalid level hangs clear error when creating the Fs

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

Fixes #10227

The zstd support removed the default from the --compress-level option
and made it required. When no level was configured the option was left
at its zero value, which meant no compression for gzip and an invalid
encoder level for zstd.

Restore the -1 default which selects the default level for the chosen
mode, and translate it to zstd's default level of 2. Also implement the
documented zstd level 0 by storing files uncompressed, and validate
levels when creating the Fs so bad values fail immediately instead of
hanging.

The compression goroutines now close the pipe with the encoder error and
the results channels are buffered, so an encoder or upload error can no
longer leave the transfer blocked forever waiting for EOF.

Fixes rclone#10227

Co-authored-by: CommandCodeBot <[email protected]>
Restore the generated option section to its base content so the
autogenerated edits check passes

Keep the configuration example and compression level explanation outside
the generated section, with option help maintained in the Go source

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix :-)

@ncw
ncw merged commit d55dd62 into rclone:master Nov 11, 2026
9 checks passed
akasakariko added a commit to akasakariko/akasakariko that referenced this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compress: the default level hangs zstd mode and leaves gzip mode uncompressed (v1.75.2)

2 participants