diff options
author | Alec Di Vito <me@alecdivito.com> | 2025-02-22 18:44:16 +0000 |
---|---|---|
committer | Alec Di Vito <me@alecdivito.com> | 2025-02-22 18:44:16 +0000 |
commit | 577044ddbd70f5f128512c1a021329fb4c7e7eb3 (patch) | |
tree | 58e00fda45a09c5d6f1ab96a11f86aae1bbf2889 /src/config.rs | |
parent | feat: implement temporary file uploads and tweak mobile design (diff) | |
download | miniserve-577044ddbd70f5f128512c1a021329fb4c7e7eb3.tar.gz miniserve-577044ddbd70f5f128512c1a021329fb4c7e7eb3.zip |
feat: address comments; add in new argument (`temp-directory`); add comments to upload code; add tests
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 449d2ae..6a048c2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -33,6 +33,9 @@ pub struct MiniserveConfig { /// Path to be served by miniserve pub path: std::path::PathBuf, + /// Temporary directory that should be used when files are uploaded to the server + pub temp_upload_directory: Option<std::path::PathBuf>, + /// Port on which miniserve will be listening pub port: u16, @@ -275,9 +278,16 @@ impl MiniserveConfig { .transpose()? .unwrap_or_default(); + let temp_upload_directory = args.temp_upload_directory.as_ref().take().map(|v| if v.exists() && v.is_dir() { + Ok(v.clone()) + } else { + Err(anyhow!("Upload temporary directory must exist and be a directory. Validate that path {v:?} meets those requirements")) + }).transpose()?; + Ok(Self { verbose: args.verbose, path: args.path.unwrap_or_else(|| PathBuf::from(".")), + temp_upload_directory, port, interfaces, auth, |