From 5d10f0c200bead79f20503ee7d4d908246d753c7 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 20 Jul 2020 16:05:11 +0200 Subject: allow zipping to be disabled If you use ezau on Windows, you might prefer to use the built-in zipping functionality from arcDPS instead of relying on ezau to do this job. However, that would lead to weird interactions because arcDPS would still create the temporary file in the watched folder, and powershell would race with ezau to zip and delete this temporary file. To prevent this from breaking existing (& working) configurations - and to stick true to the name - zipping is enabled by default if not given otherwise in the configuration. --- README.md | 6 ++++++ ezau-sample.toml | 6 ++++++ src/config.rs | 7 +++++++ src/main.rs | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c257000..d6ba347 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,12 @@ upload_unknown = false # (optional) retries = 0 +# Zip freshly created (unzipped) logs. +# Deactivate this if you use arcDPS's built-in zip functionality to prevent any +# weird interactions. +# (optional) +zip = true + # Discord messaging section. # If this section is missing, ezau will not do Discord notifications for log uploads. # Mandatory keys in this section are only mandatory if the section is present, as the whole Discord functionality is optional. diff --git a/ezau-sample.toml b/ezau-sample.toml index 77d96a8..00f8d73 100644 --- a/ezau-sample.toml +++ b/ezau-sample.toml @@ -14,6 +14,12 @@ upload_unknown = false # (optional) retries = 0 +# Zip freshly created (unzipped) logs. +# Deactivate this if you use arcDPS's built-in zip functionality to prevent any +# weird interactions. +# (optional) +zip = true + # Discord messaging section. # If this section is missing, ezau will not do Discord notifications for log uploads. # Mandatory keys in this section are only mandatory if the section is present, as the whole Discord functionality is optional. diff --git a/src/config.rs b/src/config.rs index 6b9a89d..805a2c3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -14,6 +14,9 @@ pub struct Config { /// How often the upload to dps.report should be retried. #[serde(default)] pub retries: u32, + /// Whether ezau should zip non-zipped logs. + #[serde(default = "default_zip")] + pub zip: bool, /// Option Discord information for bot postings. pub discord: Option, } @@ -32,3 +35,7 @@ pub fn load>(path: P) -> Result { let content = fs::read(path)?; Ok(toml::from_slice(&content)?) } + +fn default_zip() -> bool { + true +} diff --git a/src/main.rs b/src/main.rs index 395a0b5..d5cee18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,7 +104,7 @@ fn watch(watch: &Watch, config: &Config) -> Result<()> { if let DebouncedEvent::Create(path) = event { let path_str = path.to_str().unwrap(); // Check if we need to zip it first. - if raw_evtc_re.is_match(path_str) { + if config.zip && raw_evtc_re.is_match(path_str) { info!("Zipping up {}", path_str); zip_file(&path)?; } else if zip_evtc_re.is_match(path_str) { -- cgit v1.2.3