Skip to content

Commit

Permalink
write.c: don't read file data with --dry-run-metadata
Browse files Browse the repository at this point in the history
If we've been given --dry-run-metadata, then we only care about the
total number of bytes in each file, not the contents.
  • Loading branch information
gperciva committed Dec 26, 2023
1 parent 614335d commit e086462
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tar/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,10 @@ write_file_data(struct bsdtar *bsdtar, struct archive *a,
ssize_t bytes_written;
off_t progress = 0;

/* If we have --dry-run-metadata, don't read any file data. */
if (bsdtar->option_dryrun == 2)
return (0);

bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
while (bytes_read > 0) {
disk_pause(bsdtar->disk_pause);
Expand Down

0 comments on commit e086462

Please sign in to comment.