Skip to content

Ensure compression level zero uses parsed state#1867

Merged
oferchen merged 1 commit into
masterfrom
fix-compression-test-failure
Nov 1, 2025
Merged

Ensure compression level zero uses parsed state#1867
oferchen merged 1 commit into
masterfrom
fix-compression-test-failure

Conversation

@oferchen
Copy link
Copy Markdown
Owner

@oferchen oferchen commented Nov 1, 2025

Summary

  • reuse the parsed --compress-level value when constructing derived settings
  • avoid double-parsing compression levels so disable requests keep the CLI state consistent

Testing

  • cargo test -p rsync-cli frontend::tests::compression_tests::compress_level_zero_disables_local_compression -- --nocapture
  • cargo test -p rsync-cli frontend::tests::compression_tests -- --nocapture
  • cargo test -p rsync-cli

https://chatgpt.com/codex/tasks/task_e_6905e7874550832394da1cbd3e0dd0b9

@oferchen oferchen merged commit d5a3a44 into master Nov 1, 2025
@oferchen oferchen deleted the fix-compression-test-failure branch November 1, 2025 11:09
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 263 to +269
}
};

let mut compression_setting = CompressionSetting::default();
if let Some(value) = inputs.compress_level {
match parse_compress_level_argument(value.as_os_str()) {
Ok(setting) => {
compression_setting = setting;
compress = !setting.is_disabled();
let compression_setting = match compress_level_setting {
Some(CompressLevelArg::Disable) => CompressionSetting::disabled(),
Some(CompressLevelArg::Level(level)) => {
CompressionSetting::level(CompressionLevel::precise(level))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P0 Badge Avoid moving compress_level_setting before later use

The new logic computes compress_disabled via matches!(compress_level_setting, Some(CompressLevelArg::Disable)) and then immediately uses compress_level_setting again when building compress_level_cli and compression_setting. CompressLevelArg is not Copy, so this matches! call moves the Option and subsequent references produce a compile‑time use of moved value error. The commit as written will not build. Evaluate the predicate by reference (e.g. matches!(&compress_level_setting, …)) or otherwise avoid consuming the value before reusing it.

Useful? React with 👍 / 👎.

oferchen added a commit that referenced this pull request Apr 28, 2026
Documents the actual Windows feature state so users have realistic
expectations: ACLs (-A), xattrs (-X), symlinks, devices, and
ownership are stubbed on Windows, while permissions degrade to the
read-only flag and IOCP is implemented in fast_io but not yet wired
into the transfer pipeline. References tasks #1866 (Windows ACLs),
#1867 (Windows xattrs), and #1868 (IOCP wiring).
oferchen added a commit that referenced this pull request May 1, 2026
Documents the actual Windows feature state so users have realistic
expectations: ACLs (-A), xattrs (-X), symlinks, devices, and
ownership are stubbed on Windows, while permissions degrade to the
read-only flag and IOCP is implemented in fast_io but not yet wired
into the transfer pipeline. References tasks #1866 (Windows ACLs),
#1867 (Windows xattrs), and #1868 (IOCP wiring).
oferchen added a commit that referenced this pull request May 1, 2026
…ams (#1867)

Add a Windows backend for the cross-platform xattr layer that maps each
named extended attribute onto an NTFS Alternate Data Stream using the
`path:streamname:$DATA` syntax. The four POSIX primitives are now backed
by `FindFirstStreamW`/`FindNextStreamW` for listing, `CreateFileW` +
`ReadFile`/`WriteFile` for read and write, and `DeleteFileW` for
removal. Stream-name parsing strips the `:` prefix and `:$DATA` suffix
returned by NTFS so the wire-format names match the Unix xattr names
exposed by the existing `xattr` crate backend.

Refactor the per-attribute primitives in `crates/metadata/src/xattr.rs`
to take raw `&[u8]` names and dispatch to a platform backend module
(`xattr_unix` or `xattr_windows`). The Unix backend continues to wrap
the `xattr` crate; the new Windows backend lives in a separate file
under the same `feature = "xattr"` gate so the cross-platform layer
remains backend-agnostic. The public API (`read_xattrs_for_wire`,
`sync_xattrs`, `apply_xattrs_from_list`) is unchanged and the upstream
rsync namespace-filtering policy still applies on Linux.

Unsafe FFI is contained in `xattr_windows.rs` with `#![allow(unsafe_code)]`
matching the existing convention for platform wrappers in the metadata
crate (alongside `acl_windows`, `ownership`, `id_lookup`). Resource
management uses RAII wrappers around `FindClose` and `CloseHandle` so
handles are released on every error path.

Tests cover the stream-name parser, input validation in
`stream_path_wide`, and a write/read/list/remove round-trip that
gracefully skips when the test volume does not support ADS (e.g.
FAT32 runners).

Refs #1867
oferchen added a commit that referenced this pull request May 1, 2026
…ams (#1867)

Add a Windows backend for the cross-platform xattr layer that maps each
named extended attribute onto an NTFS Alternate Data Stream using the
`path:streamname:$DATA` syntax. The four POSIX primitives are now backed
by `FindFirstStreamW`/`FindNextStreamW` for listing, `CreateFileW` +
`ReadFile`/`WriteFile` for read and write, and `DeleteFileW` for
removal. Stream-name parsing strips the `:` prefix and `:$DATA` suffix
returned by NTFS so the wire-format names match the Unix xattr names
exposed by the existing `xattr` crate backend.

Refactor the per-attribute primitives in `crates/metadata/src/xattr.rs`
to take raw `&[u8]` names and dispatch to a platform backend module
(`xattr_unix` or `xattr_windows`). The Unix backend continues to wrap
the `xattr` crate; the new Windows backend lives in a separate file
under the same `feature = "xattr"` gate so the cross-platform layer
remains backend-agnostic. The public API (`read_xattrs_for_wire`,
`sync_xattrs`, `apply_xattrs_from_list`) is unchanged and the upstream
rsync namespace-filtering policy still applies on Linux.

Unsafe FFI is contained in `xattr_windows.rs` with `#![allow(unsafe_code)]`
matching the existing convention for platform wrappers in the metadata
crate (alongside `acl_windows`, `ownership`, `id_lookup`). Resource
management uses RAII wrappers around `FindClose` and `CloseHandle` so
handles are released on every error path.

Tests cover the stream-name parser, input validation in
`stream_path_wide`, and a write/read/list/remove round-trip that
gracefully skips when the test volume does not support ADS (e.g.
FAT32 runners).

Refs #1867
oferchen added a commit that referenced this pull request May 2, 2026
…ams (#1867)

Add a Windows backend for the cross-platform xattr layer that maps each
named extended attribute onto an NTFS Alternate Data Stream using the
`path:streamname:$DATA` syntax. The four POSIX primitives are now backed
by `FindFirstStreamW`/`FindNextStreamW` for listing, `CreateFileW` +
`ReadFile`/`WriteFile` for read and write, and `DeleteFileW` for
removal. Stream-name parsing strips the `:` prefix and `:$DATA` suffix
returned by NTFS so the wire-format names match the Unix xattr names
exposed by the existing `xattr` crate backend.

Refactor the per-attribute primitives in `crates/metadata/src/xattr.rs`
to take raw `&[u8]` names and dispatch to a platform backend module
(`xattr_unix` or `xattr_windows`). The Unix backend continues to wrap
the `xattr` crate; the new Windows backend lives in a separate file
under the same `feature = "xattr"` gate so the cross-platform layer
remains backend-agnostic. The public API (`read_xattrs_for_wire`,
`sync_xattrs`, `apply_xattrs_from_list`) is unchanged and the upstream
rsync namespace-filtering policy still applies on Linux.

Unsafe FFI is contained in `xattr_windows.rs` with `#![allow(unsafe_code)]`
matching the existing convention for platform wrappers in the metadata
crate (alongside `acl_windows`, `ownership`, `id_lookup`). Resource
management uses RAII wrappers around `FindClose` and `CloseHandle` so
handles are released on every error path.

Tests cover the stream-name parser, input validation in
`stream_path_wide`, and a write/read/list/remove round-trip that
gracefully skips when the test volume does not support ADS (e.g.
FAT32 runners).

Refs #1867
oferchen added a commit that referenced this pull request May 2, 2026
…ams (#1867) (#3536)

* feat(metadata): implement Windows xattrs via NTFS Alternate Data Streams (#1867)

Add a Windows backend for the cross-platform xattr layer that maps each
named extended attribute onto an NTFS Alternate Data Stream using the
`path:streamname:$DATA` syntax. The four POSIX primitives are now backed
by `FindFirstStreamW`/`FindNextStreamW` for listing, `CreateFileW` +
`ReadFile`/`WriteFile` for read and write, and `DeleteFileW` for
removal. Stream-name parsing strips the `:` prefix and `:$DATA` suffix
returned by NTFS so the wire-format names match the Unix xattr names
exposed by the existing `xattr` crate backend.

Refactor the per-attribute primitives in `crates/metadata/src/xattr.rs`
to take raw `&[u8]` names and dispatch to a platform backend module
(`xattr_unix` or `xattr_windows`). The Unix backend continues to wrap
the `xattr` crate; the new Windows backend lives in a separate file
under the same `feature = "xattr"` gate so the cross-platform layer
remains backend-agnostic. The public API (`read_xattrs_for_wire`,
`sync_xattrs`, `apply_xattrs_from_list`) is unchanged and the upstream
rsync namespace-filtering policy still applies on Linux.

Unsafe FFI is contained in `xattr_windows.rs` with `#![allow(unsafe_code)]`
matching the existing convention for platform wrappers in the metadata
crate (alongside `acl_windows`, `ownership`, `id_lookup`). Resource
management uses RAII wrappers around `FindClose` and `CloseHandle` so
handles are released on every error path.

Tests cover the stream-name parser, input validation in
`stream_path_wide`, and a write/read/list/remove round-trip that
gracefully skips when the test volume does not support ADS (e.g.
FAT32 runners).

Refs #1867

* style(metadata): cargo fmt

* fix(metadata): make ADS xattr impl cross-compile for windows-gnu

The Windows ADS xattr backend used `windows::Win32::Storage::FileSystem::{
ReadFile, WriteFile}`, which are gated behind the `Win32_System_IO`
feature in `windows = "0.62"`. Cross-compiling to
`x86_64-pc-windows-gnu` therefore failed with `no `ReadFile` /
`WriteFile` in `Win32::Storage::FileSystem``. `FindFirstStreamW`'s
`dwflags` argument also takes `Option<u32>`, but the call site passed a
bare `0`.

Replace the raw `ReadFile`/`WriteFile` calls with `std::fs::File`
constructed from the Win32 `HANDLE` via `FromRawHandle`, so the read
and write paths use stdlib I/O instead of FFI bindings that depend on
an additional `windows` crate feature. The `File` takes ownership of
the handle and closes it on drop, replacing the now-unused
`OwnedHandle` wrapper. Wrap the reserved-must-be-zero `dwflags`
argument in `Some(0)` to match the binding signature.

No new Cargo features and no changes outside `crates/metadata/`.

* style(metadata): cargo fmt xattr_windows imports
oferchen added a commit that referenced this pull request May 5, 2026
Documents the actual Windows feature state so users have realistic
expectations: ACLs (-A), xattrs (-X), symlinks, devices, and
ownership are stubbed on Windows, while permissions degrade to the
read-only flag and IOCP is implemented in fast_io but not yet wired
into the transfer pipeline. References tasks #1866 (Windows ACLs),
#1867 (Windows xattrs), and #1868 (IOCP wiring).
oferchen added a commit that referenced this pull request May 5, 2026
…ams (#1867) (#3536)

* feat(metadata): implement Windows xattrs via NTFS Alternate Data Streams (#1867)

Add a Windows backend for the cross-platform xattr layer that maps each
named extended attribute onto an NTFS Alternate Data Stream using the
`path:streamname:$DATA` syntax. The four POSIX primitives are now backed
by `FindFirstStreamW`/`FindNextStreamW` for listing, `CreateFileW` +
`ReadFile`/`WriteFile` for read and write, and `DeleteFileW` for
removal. Stream-name parsing strips the `:` prefix and `:$DATA` suffix
returned by NTFS so the wire-format names match the Unix xattr names
exposed by the existing `xattr` crate backend.

Refactor the per-attribute primitives in `crates/metadata/src/xattr.rs`
to take raw `&[u8]` names and dispatch to a platform backend module
(`xattr_unix` or `xattr_windows`). The Unix backend continues to wrap
the `xattr` crate; the new Windows backend lives in a separate file
under the same `feature = "xattr"` gate so the cross-platform layer
remains backend-agnostic. The public API (`read_xattrs_for_wire`,
`sync_xattrs`, `apply_xattrs_from_list`) is unchanged and the upstream
rsync namespace-filtering policy still applies on Linux.

Unsafe FFI is contained in `xattr_windows.rs` with `#![allow(unsafe_code)]`
matching the existing convention for platform wrappers in the metadata
crate (alongside `acl_windows`, `ownership`, `id_lookup`). Resource
management uses RAII wrappers around `FindClose` and `CloseHandle` so
handles are released on every error path.

Tests cover the stream-name parser, input validation in
`stream_path_wide`, and a write/read/list/remove round-trip that
gracefully skips when the test volume does not support ADS (e.g.
FAT32 runners).

Refs #1867

* style(metadata): cargo fmt

* fix(metadata): make ADS xattr impl cross-compile for windows-gnu

The Windows ADS xattr backend used `windows::Win32::Storage::FileSystem::{
ReadFile, WriteFile}`, which are gated behind the `Win32_System_IO`
feature in `windows = "0.62"`. Cross-compiling to
`x86_64-pc-windows-gnu` therefore failed with `no `ReadFile` /
`WriteFile` in `Win32::Storage::FileSystem``. `FindFirstStreamW`'s
`dwflags` argument also takes `Option<u32>`, but the call site passed a
bare `0`.

Replace the raw `ReadFile`/`WriteFile` calls with `std::fs::File`
constructed from the Win32 `HANDLE` via `FromRawHandle`, so the read
and write paths use stdlib I/O instead of FFI bindings that depend on
an additional `windows` crate feature. The `File` takes ownership of
the handle and closes it on drop, replacing the now-unused
`OwnedHandle` wrapper. Wrap the reserved-must-be-zero `dwflags`
argument in `Some(0)` to match the binding signature.

No new Cargo features and no changes outside `crates/metadata/`.

* style(metadata): cargo fmt xattr_windows imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant