Skip to content

Preserve file modes during atomic saves - #64

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/preserve-atomic-file-mode
Open

Preserve file modes during atomic saves#64
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/preserve-atomic-file-mode

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Copy the existing store mode to the temporary file before an atomic rename. This prevents an atomic transaction from replacing a deliberately restricted file with the process-default creation mode.

Reproduction

Create a PStore, chmod it to modes such as 0600, 0640, 0750 or 06750, then commit an atomic transaction. Current master recreates the path with a mode derived from 0666 and umask; this change retains the original permission and special-mode bits.

Verification

  • Existing suite: 13 tests / 26 assertions on Ruby 4.0.6 and 3.2.11.
  • External metadata model: 21 mode, uid and gid checks per Ruby, including special bits.
  • Exact 14-path gem package build, install and load on both Rubies.
  • Syntax and existing lint baseline checked; no repository tests changed.

Compatibility and limits

The change only affects changed atomic writes. It preserves permission bits, not ownership, ACLs, extended attributes, hard-link identity, or broader crash, NFS and Windows semantics. Local bounded measurements show the extra stat and chmod cost only on atomic replacement.

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.

1 participant