Skip to content

extract: restore directory modification times from the archive - #412

Open
jayhemnani9910 wants to merge 1 commit into
uutils:mainfrom
jayhemnani9910:extract-directory-mtimes
Open

jayhemnani9910 wants to merge 1 commit into
uutils:mainfrom
jayhemnani9910:extract-directory-mtimes

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Depends on #411 (directories are unpacked after their contents).

Extracted directories keep the time they were created, or the time the last file was written into them. tar-rs sets the mtime of files only. GNU tar restores directory mtimes too:

$ tar -xf g.tar        # directories d, d/e, emptydir archived with mtime 1792609704
GNU tar 1.35:  d 1792609704   d/e 1792609704   emptydir 1792609704
uutils:        d 1792609843   d/e 1792609843   emptydir 1792609843   (extraction time)

After a directory member is unpacked, its mtime is set from the header with filetime. filetime was already in Cargo.lock through tar-rs and is now a direct dependency, because it can set times on directories on Windows too. Negative times are kept, as tar-rs does for files. If the time can't be set (for example on ./ in a directory owned by someone else), tar prints Cannot utime and exits 2 at the end, like GNU tar, instead of stopping.

New test test_extract_keeps_directory_mtime fails without the change. cargo test --workspace: 111 passed, clippy and fmt clean. Directory mtimes, including . from a ./ member and a negative time, match GNU tar 1.35. Limits: the PAX mtime record isn't used (tar-rs reads the header field only, for files too).

Copilot AI balanced review requested due to automatic review settings October 22, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.19608% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.97%. Comparing base (791ae26) to head (0447c11).
⚠️ Report is 100 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/tar/src/operations/extract.rs 75.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #412      +/-   ##
==========================================
+ Coverage   96.84%   97.97%   +1.12%     
==========================================
  Files          11       15       +4     
  Lines        1492     2020     +528     
  Branches       29       42      +13     
==========================================
+ Hits         1445     1979     +534     
+ Misses         46       40       -6     
  Partials        1        1              
Flag Coverage Δ
macos_latest 97.97% <90.19%> (+1.12%) ⬆️
ubuntu_latest 97.97% <90.19%> (+1.12%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 7 untouched benchmarks


Comparing jayhemnani9910:extract-directory-mtimes (0447c11) with main (b453849)

Open in CodSpeed

Copilot AI balanced review requested due to automatic review settings October 23, 2026 10:43
@jayhemnani9910
jayhemnani9910 force-pushed the extract-directory-mtimes branch from 6c7fea0 to 0447c11 Compare October 23, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

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.

2 participants