aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock6
-rw-r--r--Cargo.toml2
-rw-r--r--src/archive.rs14
-rw-r--r--src/listing.rs2
4 files changed, 11 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ff7dbc3..26f6848 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -788,7 +788,7 @@ dependencies = [
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "tar 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)",
"yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1371,7 +1371,7 @@ dependencies = [
[[package]]
name = "tar"
-version = "0.4.21"
+version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2029,7 +2029,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6"
"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
-"checksum tar 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)" = "904b43da53c99b929c4484fa281e5535f2eb86b3040de3e3e5b69708e2a8bd65"
+"checksum tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c2167ff53da2a661702b3299f71a91b61b1dffef36b4b2884b1f9c67254c0133"
"checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
diff --git a/Cargo.toml b/Cargo.toml
index e9cce56..6f4aa16 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,7 +37,7 @@ chrono = "0.4.6"
chrono-humanize = "0.0.11"
maud = { version = "0.20.0", features = ["actix-web"] }
serde = { version = "1.0.89", features = ["derive"] }
-tar = "0.4"
+tar = "0.4.22"
bytes = "0.4.12"
futures = "0.1.25"
libflate = "0.1.21"
diff --git a/src/archive.rs b/src/archive.rs
index b71d50f..b351fb9 100644
--- a/src/archive.rs
+++ b/src/archive.rs
@@ -49,14 +49,15 @@ impl CompressionMethod {
pub fn create_archive_file(
method: &CompressionMethod,
dir: &PathBuf,
+ skip_symlinks: bool
) -> Result<(String, Bytes), errors::CompressionError> {
match method {
- CompressionMethod::TarGz => tgz_compress(&dir),
+ CompressionMethod::TarGz => tgz_compress(&dir, skip_symlinks),
}
}
/// Compresses a given folder in .tar.gz format
-fn tgz_compress(dir: &PathBuf) -> Result<(String, Bytes), errors::CompressionError> {
+fn tgz_compress(dir: &PathBuf, skip_symlinks: bool) -> Result<(String, Bytes), errors::CompressionError> {
let src_dir = dir.display().to_string();
let inner_folder = match dir.file_name() {
Some(directory_name) => match directory_name.to_str() {
@@ -76,7 +77,7 @@ fn tgz_compress(dir: &PathBuf) -> Result<(String, Bytes), errors::CompressionErr
let dst_filename = format!("{}.tar", inner_folder);
let dst_tgz_filename = format!("{}.gz", dst_filename);
- let tar_content = tar(src_dir, inner_folder.to_string())
+ let tar_content = tar(src_dir, inner_folder.to_string(), skip_symlinks)
.context(errors::CompressionErrorKind::TarContentError)?;
let gz_data = gzip(&tar_content).context(errors::CompressionErrorKind::GZipContentError)?;
@@ -87,14 +88,11 @@ fn tgz_compress(dir: &PathBuf) -> Result<(String, Bytes), errors::CompressionErr
}
/// Creates a temporary tar file of a given directory, reads it and returns its content as bytes
-fn tar(src_dir: String, inner_folder: String) -> Result<Vec<u8>, errors::CompressionError> {
+fn tar(src_dir: String, inner_folder: String, skip_symlinks: bool) -> Result<Vec<u8>, errors::CompressionError> {
// Create a TAR file of src_dir
let mut tar_builder = Builder::new(Vec::new());
- // Temporary workaround for known issue:
- // https://github.com/alexcrichton/tar-rs/issues/147
- // https://github.com/alexcrichton/tar-rs/issues/174
- tar_builder.follow_symlinks(false);
+ tar_builder.follow_symlinks(!skip_symlinks);
tar_builder.append_dir_all(inner_folder, &src_dir).context(
errors::CompressionErrorKind::TarBuildingError {
message: format!(
diff --git a/src/listing.rs b/src/listing.rs
index b820aa4..a243c22 100644
--- a/src/listing.rs
+++ b/src/listing.rs
@@ -233,7 +233,7 @@ pub fn directory_listing<S>(
extension = compression_method.extension(),
path = &dir.path.display().to_string()
);
- match archive::create_archive_file(&compression_method, &dir.path) {
+ match archive::create_archive_file(&compression_method, &dir.path, skip_symlinks) {
Ok((filename, content)) => {
log::info!("{file} successfully created !", file = &filename);
Ok(HttpResponse::Ok()