Skip to content

Commit

Permalink
Fix handling contents added after header creation
Browse files Browse the repository at this point in the history
Addresses #282.

Signed-off-by: Grant Elbert <grant.elbert@smartthings.com>
  • Loading branch information
elbe0046 committed Mar 3, 2022
1 parent c3e2cb8 commit 9edb4c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/builder.rs
Expand Up @@ -444,7 +444,8 @@ fn append_path_with_name(
};
let ar_name = name.unwrap_or(path);
if stat.is_file() {
append_fs(dst, ar_name, &stat, &mut fs::File::open(path)?, mode, None)
let file = fs::File::open(path)?;
append_fs(dst, ar_name, &stat, &mut file.take(stat.len()), mode, None)
} else if stat.is_dir() {
append_fs(dst, ar_name, &stat, &mut io::empty(), mode, None)
} else if stat.file_type().is_symlink() {
Expand Down Expand Up @@ -520,7 +521,7 @@ fn append_file(
mode: HeaderMode,
) -> io::Result<()> {
let stat = file.metadata()?;
append_fs(dst, path, &stat, file, mode, None)
append_fs(dst, path, &stat, &mut file.take(stat.len()), mode, None)
}

fn append_dir(
Expand Down

0 comments on commit 9edb4c2

Please sign in to comment.