Skip to content

fix: keep file modification times in tar archives - #149

Open
jayhemnani9910 wants to merge 1 commit into
node-modules:masterfrom
jayhemnani9910:fix/tar-keep-mtime
Open

jayhemnani9910 wants to merge 1 commit into
node-modules:masterfrom
jayhemnani9910:fix/tar-keep-mtime

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Nov 15, 2026 •

Copy link
Copy Markdown

tar.compressDir, tar.compressFile and their tgz versions write every file with the time of the run instead of its modification time:

touch -d '2020-01-02 03:04:05Z' proj/src/a.txt
node -e "require('compressing').tar.compressDir('proj', 'p.tar')"
tar tvf p.tar   # -rw-r--r-- 0/0  3 2026-11-14 22:50 proj/src/a.txt

zip.compressDir keeps the time. The tar headers (in lib/tar/stream.js and lib/tar/file_stream.js) are built with name, size and mode only, and tar-stream uses the current time when mtime is missing. Both now pass mtime: stat.mtime.

Added tests for compressDir and compressFile that read the header back with tar-stream; they fail without the change. npm run test:js passes apart from tgz.uncompress(sourceFile, destDir), which fails the same way without the change here.

Summary by CodeRabbit

  • Bug Fixes
    • TAR archives now preserve source files’ modification times for both file and directory compression.

@agentscanapp

agentscanapp Bot commented Nov 15, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Report this account →

Evidence
  • Severe fork surge: 28 repositories forked in rapid succession (within 24 hours)
  • Very high PR volume (daily): 52 PRs within a single 24-hour window
  • High PR volume (weekly): 52 PRs within a single 7-day window

Last 5 PRs:

This is an automated analysis by AgentScan

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

TAR entries created from files now include the source file’s modification time. Tests check the time for file and directory compression.

Changes: TAR modification time

Layer / File(s) Summary
Propagate and verify modification time
lib/tar/file_stream.js, lib/tar/stream.js, test/tar/index.test.js
Both TAR entry creation paths include the source file’s modification time. Tests verify that file and directory compression preserve the time in TAR headers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: popomore

Merge Risk: Minimal · up to dff71

Tar archives now keep the source files' modification times instead of the compression time. The change is small and covered by tests, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: keep file modification times in tar archives" matches the main change. The summary says both lib/tar/stream.js and lib/tar/file_stream.js now pass stat.mtime into tar entry metadata, a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix: keep file modification times in tar archives" matches the main change. The summary says both lib/tar/stream.js and lib/tar/file_stream.js now pass stat.mtime into tar entry metadata, and tests verify that the extracted entries keep the set modification time. The title is concise, specific, and free of noise.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

lib/tar/file_stream.js

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

lib/tar/stream.js

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

test/tar/index.test.js

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0ea23d4-da9c-4ef0-a175-c565fe4d8849
Commits

Reviewing files that changed from the base of the PR and between 806be7f and dff7132.

Files selected for processing: 3

  • lib/tar/file_stream.js
  • lib/tar/stream.js
  • test/tar/index.test.js

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant