From 42df2815c3682b737ec69981e5c7976dc2fee44b Mon Sep 17 00:00:00 2001 From: Araozu Date: Fri, 17 Nov 2023 15:25:40 -0500 Subject: [PATCH] [BE][Scans] Delete files after conversion --- backend/Cargo.lock | 78 ----------------------------- backend/Cargo.toml | 1 - backend/src/controller/scans/mod.rs | 9 +++- 3 files changed, 8 insertions(+), 80 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index ff56ae3..490b06b 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -143,7 +143,6 @@ dependencies = [ "lazy_static", "log", "once_cell", - "printpdf", "reqwest", "rocket", "scraper", @@ -228,17 +227,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bstr" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" -dependencies = [ - "memchr", - "regex-automata 0.3.6", - "serde", -] - [[package]] name = "bumpalo" version = "3.13.0" @@ -1436,12 +1424,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.4.5" @@ -1479,23 +1461,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "lopdf" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c8e1b6184b1b32ea5f72f572ebdc40e5da1d2921fa469947ff7c480ad1f85a" -dependencies = [ - "encoding_rs", - "flate2", - "itoa", - "linked-hash-map", - "log", - "md5", - "pom", - "time 0.3.27", - "weezl", -] - [[package]] name = "mac" version = "0.1.1" @@ -1540,12 +1505,6 @@ dependencies = [ "digest", ] -[[package]] -name = "md5" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" - [[package]] name = "memchr" version = "2.5.0" @@ -1801,15 +1760,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "owned_ttf_parser" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60ac8dda2e5cc09bf6480e3b3feff9783db251710c922ae9369a429c51efdeb0" -dependencies = [ - "ttf-parser", -] - [[package]] name = "parking" version = "2.1.1" @@ -2051,15 +2001,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "pom" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2d73a5fe10d458e77534589512104e5aa8ac480aa9ac30b74563274235cce4" -dependencies = [ - "bstr", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2072,19 +2013,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" -[[package]] -name = "printpdf" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f626e180738289baa7ea2d70e603698520735060a664141203cc17bd8e4379c0" -dependencies = [ - "image", - "js-sys", - "lopdf", - "owned_ttf_parser", - "time 0.3.27", -] - [[package]] name = "proc-macro2" version = "1.0.66" @@ -3419,12 +3347,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "ttf-parser" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae2f58a822f08abdaf668897e96a5656fe72f5a9ce66422423e8849384872e6" - [[package]] name = "typenum" version = "1.16.0" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index dc22f65..fb58c88 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -21,6 +21,5 @@ log = "0.4.20" env_logger = "0.10.0" bardecoder = "0.5.0" image = "0.24.7" -printpdf = { version = "0.6.0", features = ["image", "embedded_images"] } diff --git a/backend/src/controller/scans/mod.rs b/backend/src/controller/scans/mod.rs index 4f027c9..ed8612d 100644 --- a/backend/src/controller/scans/mod.rs +++ b/backend/src/controller/scans/mod.rs @@ -321,7 +321,14 @@ async fn convert_scans_from_data(data: &Vec<(PathBuf, ScanInfo)>) -> Result<(), match convert_to_pdf(&image_path, &output_path) { Ok(_) => { - log::info!("Converted file: {}", filename) + log::info!("Converted file: {}", filename); + // Delete image + match fs::remove_file(image_path) { + Ok(_) => log::info!("Deleted image for: {}", filename), + Err(err) => { + log::error!("Error deleting image for {}: {:?}", filename, err); + } + } } Err(reason) => { log::error!("Error converting to pdf: {}", reason);