From bc293fa54a612ff7e2d6088ba5d91890cad75b81 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Fri, 15 Mar 2019 17:50:59 +0100 Subject: Renamed create_archive_file function and added documentation --- src/archive.rs | 10 ++++++---- src/listing.rs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') 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, 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( 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() -- cgit v1.2.3