Skip to content

feat(cli): apply aliasing checks and atomic temp-file publish to decompress #46

Description

@coderabbitai

Summary

The compress command in cli/src/main.rs was hardened in #45 with:

  • Aliasing checks (ensure_distinct_paths / paths_point_to_same_file) to reject identical or hard-linked input/output paths before any I/O.
  • Atomic temporary-file publish (create_temporary_output_file + replace_output_file) so the final destination is only replaced after a fully successful write, with permission preservation and platform-specific rename semantics.

The decompress command currently has neither of these protections. This issue tracks applying the same pattern to decompress.

Work items

  • Call ensure_distinct_paths at the start of decompress (before opening files).
  • Stream decompressed output to a temporary file via create_temporary_output_file.
  • On successful completion, promote the temp file to the final destination via replace_output_file.
  • On failure, clean up the temp file (mirror the compress error-path cleanup).
  • Add tests analogous to the compress tests for aliasing rejection and temp-file cleanup on failure.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions