diff --git a/Cargo.lock b/Cargo.lock index 54e31a5..cc73f82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1057,9 +1057,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.165" +version = "0.2.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e" +checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" [[package]] name = "libm" @@ -1190,7 +1190,7 @@ dependencies = [ [[package]] name = "nhentai_archivist" -version = "3.6.1" +version = "3.6.2" dependencies = [ "chrono", "load_config", @@ -1622,9 +1622,9 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" dependencies = [ "const-oid", "digest", @@ -2361,9 +2361,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 05d567d..d7eb04b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" name = "nhentai_archivist" readme = "readme.md" repository = "https://github.com/9-FS/nhentai_archivist" -version = "3.6.1" +version = "3.6.2" [dependencies] chrono = { version = "^0.4.0", features = ["serde"] } diff --git a/docker-compose.yaml b/docker-compose.yaml index 8d61fcf..247bc75 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,7 @@ services: nhentai_archivist: container_name: "nhentai_archivist" - image: "ghcr.io/9-fs/nhentai_archivist:3.6.1" + image: "ghcr.io/9-fs/nhentai_archivist:3.6.2" environment: HOST_OS: "Unraid" TZ: "UTC" diff --git a/src/hentai.rs b/src/hentai.rs index 2421a36..90609e6 100644 --- a/src/hentai.rs +++ b/src/hentai.rs @@ -167,7 +167,7 @@ impl Hentai { const WORKERS: usize = 5; // number of parallel workers let cbz_final_filepath: String; //filepath to final cbz in library - let cbz_temp_filepath: String = format!("{}{}/{}", self.library_path, self.id, self.cbz_filename); //filepath to temporary cbz, cbz is created here and when finished moved to final location, roundabout way over temporary cbz filepath in case program gets stopped while creating cbz, so no half finished cbz remains in library + let cbz_temp_filepath: String = format!("{}{}/{}.temp", self.library_path, self.id, self.cbz_filename); //filepath to temporary cbz, cbz is created here and when finished moved to final location, roundabout way over temporary cbz filepath in case program gets stopped while creating cbz, so no half finished cbz remains in library let comicinfoxml_filepath: String = format!("{}{}/ComicInfo.xml", self.library_path, self.id); // filepath to metadata file if cleanup_temporary_files is false let f = scaler::Formatter::new() .set_scaling(scaler::Scaling::None) @@ -178,21 +178,12 @@ impl Hentai let mut zip_writer: zip::ZipWriter; // write to zip file - if self.library_split == 0 // no library split + cbz_final_filepath = match self.library_split // determine final cbz filepath { - cbz_final_filepath = format!("{}{}", self.library_path, self.cbz_filename); - } - else // with library split - { - cbz_final_filepath = format! - ( - "{}{}~{}/{}", - self.library_path.to_owned(), - self.id.div_euclid(self.library_split) * self.library_split, - (self.id.div_euclid(self.library_split) + 1) * self.library_split - 1, - self.cbz_filename, - ); - } + 0 => format!("{}{}", self.library_path, self.cbz_filename), // no library split + 1 => format!("{}{}/{}", self.library_path, self.id, self.cbz_filename), // library split into directories with single hentai per directory + _ => format!("{}{}~{}/{}", self.library_path, self.id.div_euclid(self.library_split) * self.library_split, (self.id.div_euclid(self.library_split) + 1) * self.library_split - 1, self.cbz_filename), // library split into directories with multiple hentai per directory + }; if let Ok(o) = tokio::fs::metadata(cbz_final_filepath.as_str()).await { @@ -298,10 +289,13 @@ impl Hentai if cleanup_temporary_files // if temporary files should be cleaned up { - match tokio::fs::remove_dir_all(format!("{}{}", self.library_path, self.id)).await // cleanup, delete image directory + for image_filename in self.images_filename.iter() // cleanup, don't just delete directory because with library split = 1 would also delete final hentai cbz { - Ok(_) => log::debug!("Deleted \"{}{}/\".", self.library_path, self.id), - Err(e) => log::warn!("Deleting \"{}{}/\" failed with: {e}", self.library_path, self.id), + match tokio::fs::remove_file(format!("{}{}/{}", self.library_path, self.id, image_filename)).await // delete images + { + Ok(_) => log::debug!("Deleted \"{}{}/{}\".", self.library_path, self.id, image_filename), + Err(e) => log::warn!("Deleting \"{}{}/{}\" failed with: {e}", self.library_path, self.id, image_filename), + } } } else // if temporary files should not be cleaned up