Skip to content

Commit 5af1623

Browse files
committed
change needed to preserve permissions in astral-tokio-tar
1 parent 939787c commit 5af1623

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

crates/lib/src/install.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
};
77
use tempfile::tempdir_in;
88
use tokio::task;
9-
use tokio_tar::Archive;
9+
use tokio_tar::ArchiveBuilder;
1010

1111
// Compatibility trait lets us call `compat()` on a futures::io::AsyncRead
1212
// to convert it into a tokio::io::AsyncRead.
@@ -108,7 +108,9 @@ where
108108
let temp_dir = tempdir_in(config.pkgx_dir.join(&pkg.project))?;
109109

110110
// Step 4: Extract the tar archive
111-
let mut archive = Archive::new(decoder);
111+
let mut archive = ArchiveBuilder::new(decoder)
112+
.set_preserve_permissions(true)
113+
.build();
112114
archive.unpack(&temp_dir).await?;
113115

114116
// Step 5: atomically move from temp dir to installation location

crates/lib/src/sync.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use fs2::FileExt;
44
use futures::TryStreamExt;
55
use rusqlite::Connection;
66
use std::{error::Error, fs::OpenOptions, path::PathBuf};
7-
use tokio_tar::Archive;
7+
use tokio_tar::ArchiveBuilder;
88
use tokio_util::compat::FuturesAsyncReadCompatExt;
99

1010
#[allow(clippy::all)]
@@ -64,7 +64,9 @@ async fn download_and_extract_pantry(url: &str, dest: &PathBuf) -> Result<(), Bo
6464
let decoder = XzDecoder::new(stream);
6565

6666
// Step 3: Extract the tar archive
67-
let mut archive = Archive::new(decoder);
67+
let mut archive = ArchiveBuilder::new(decoder)
68+
.set_preserve_permissions(true)
69+
.build();
6870
archive.unpack(dest).await?;
6971

7072
Ok(())

0 commit comments

Comments
 (0)