aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorboasting-squirrel <boasting.squirrel@gmail.com>2019-03-15 16:50:59 +0000
committerboasting-squirrel <boasting.squirrel@gmail.com>2019-03-15 16:50:59 +0000
commitbc293fa54a612ff7e2d6088ba5d91890cad75b81 (patch)
treed228c1a05877449bd7ac157d7e9dbed2b8f3345e /src
parentImproved design (diff)
downloadminiserve-bc293fa54a612ff7e2d6088ba5d91890cad75b81.tar.gz
miniserve-bc293fa54a612ff7e2d6088ba5d91890cad75b81.zip
Renamed create_archive_file function and added documentation
Diffstat (limited to '')
-rw-r--r--src/archive.rs10
-rw-r--r--src/listing.rs2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/archive.rs b/src/archive.rs
index c536c2d..bc8ea3b 100644
--- a/src/archive.rs
+++ b/src/archive.rs
@@ -46,7 +46,9 @@ impl CompressionMethod {
}
}
-pub fn create_archive_file(
+/// Creates an archive of a folder, using the algorithm the user chose from the web interface
+/// This method returns the archive as a stream of bytes
+pub fn create_archive(
method: &CompressionMethod,
dir: &PathBuf,
skip_symlinks: bool,
@@ -56,7 +58,7 @@ pub fn create_archive_file(
}
}
-/// Compresses a given folder in .tar.gz format
+/// Compresses a given folder in .tar.gz format, and returns the result as a stream of bytes
fn tgz_compress(
dir: &PathBuf,
skip_symlinks: bool,
@@ -90,7 +92,7 @@ fn tgz_compress(
Ok((dst_tgz_filename, data))
}
-/// Creates a temporary tar file of a given directory, reads it and returns its content as bytes
+/// Creates a TAR archive of a folder, and returns it as a stream of bytes
fn tar(
src_dir: String,
inner_folder: String,
@@ -119,7 +121,7 @@ fn tar(
Ok(tar_content)
}
-/// Compresses a stream of bytes using the GZIP algorithm
+/// Compresses a stream of bytes using the GZIP algorithm, and returns the resulting stream
fn gzip(mut data: &[u8]) -> Result<Vec<u8>, errors::CompressionError> {
let mut encoder =
Encoder::new(Vec::new()).context(errors::CompressionErrorKind::GZipBuildingError {
diff --git a/src/listing.rs b/src/listing.rs
index a243c22..ed3b63d 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, skip_symlinks) {
+ match archive::create_archive(&compression_method, &dir.path, skip_symlinks) {
Ok((filename, content)) => {
log::info!("{file} successfully created !", file = &filename);
Ok(HttpResponse::Ok()