aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/archive.rs')
-rw-r--r--src/archive.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/archive.rs b/src/archive.rs
index 785e1e8..c96814f 100644
--- a/src/archive.rs
+++ b/src/archive.rs
@@ -1,7 +1,6 @@
use actix_web::http::ContentEncoding;
use libflate::gzip::Encoder;
use zip::{ZipWriter, write};
-use std::io::BufWriter;
use std::fs::File;
use std::path::PathBuf;
use serde::Deserialize;
@@ -54,6 +53,14 @@ impl CompressionMethod {
}
}
+ pub fn is_enabled(self, tar_enabled: bool, zip_enabled: bool,) -> bool {
+ match self {
+ CompressionMethod::TarGz => tar_enabled,
+ CompressionMethod::Tar => tar_enabled,
+ CompressionMethod::Zip => zip_enabled,
+ }
+ }
+
/// Make an archive out of the given directory, and write the output to the given writer.
///
/// Recursively includes all files and subdirectories.
@@ -258,7 +265,9 @@ where
}
}
- zip_writer.finish().unwrap();
+ zip_writer.finish().map_err(|_| {
+ ContextualError::CustomError("Could not finish writing ZIP archive".to_string())
+ })?;
Ok(())
}