From 08f6bc54dac113995fb5e3c138bdc50e2ae75905 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Sun, 18 Apr 2021 05:49:52 +0200 Subject: Rename compression code references to 'archive' This name more closely resembles its purpose. For instance, we also now support plain tar archives which are uncompressed but archives nonetheless. --- src/listing.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/listing.rs') diff --git a/src/listing.rs b/src/listing.rs index dcaed96..013265c 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -12,7 +12,7 @@ use std::path::{Component, Path, PathBuf}; use std::time::SystemTime; use strum_macros::{Display, EnumString}; -use crate::archive::CompressionMethod; +use crate::archive::ArchiveMethod; use crate::errors::{self, ContextualError}; use crate::renderer; use percent_encode_sets::PATH_SEGMENT; @@ -34,7 +34,7 @@ pub struct QueryParameters { pub sort: Option, pub order: Option, qrcode: Option, - download: Option, + download: Option, } /// Available sorting methods @@ -338,8 +338,8 @@ pub fn directory_listing( entries.sort_by_key(|e| !e.is_dir()); } - if let Some(compression_method) = query_params.download { - if !compression_method.is_enabled(tar_enabled, tar_gz_enabled, zip_enabled) { + if let Some(archive_method) = query_params.download { + if !archive_method.is_enabled(tar_enabled, tar_gz_enabled, zip_enabled) { return Ok(ServiceResponse::new( req.clone(), HttpResponse::Forbidden() @@ -365,14 +365,14 @@ pub fn directory_listing( } log::info!( "Creating an archive ({extension}) of {path}...", - extension = compression_method.extension(), + extension = archive_method.extension(), path = &dir.path.display().to_string() ); let file_name = format!( "{}.{}", dir.path.file_name().unwrap().to_str().unwrap(), - compression_method.extension() + archive_method.extension() ); // We will create the archive in a separate thread, and stream the content using a pipe. @@ -384,7 +384,7 @@ pub fn directory_listing( // Start the actual archive creation in a separate thread. let dir = dir.path.to_path_buf(); std::thread::spawn(move || { - if let Err(err) = compression_method.create_archive(dir, skip_symlinks, pipe) { + if let Err(err) = archive_method.create_archive(dir, skip_symlinks, pipe) { log::error!("Error during archive creation: {:?}", err); } }); @@ -392,8 +392,8 @@ pub fn directory_listing( Ok(ServiceResponse::new( req.clone(), HttpResponse::Ok() - .content_type(compression_method.content_type()) - .encoding(compression_method.content_encoding()) + .content_type(archive_method.content_type()) + .encoding(archive_method.content_encoding()) .header("Content-Transfer-Encoding", "binary") .header( "Content-Disposition", -- cgit v1.2.3