[BE][Scans] Delete files after conversion

This commit is contained in:
Araozu 2023-11-17 15:25:40 -05:00
parent f86131d3a5
commit 42df2815c3
3 changed files with 8 additions and 80 deletions

78
backend/Cargo.lock generated
View File

@ -143,7 +143,6 @@ dependencies = [
"lazy_static", "lazy_static",
"log", "log",
"once_cell", "once_cell",
"printpdf",
"reqwest", "reqwest",
"rocket", "rocket",
"scraper", "scraper",
@ -228,17 +227,6 @@ dependencies = [
"generic-array", "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]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.13.0" version = "3.13.0"
@ -1436,12 +1424,6 @@ dependencies = [
"vcpkg", "vcpkg",
] ]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.5" version = "0.4.5"
@ -1479,23 +1461,6 @@ dependencies = [
"tracing-subscriber", "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]] [[package]]
name = "mac" name = "mac"
version = "0.1.1" version = "0.1.1"
@ -1540,12 +1505,6 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "md5"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.5.0"
@ -1801,15 +1760,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" 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]] [[package]]
name = "parking" name = "parking"
version = "2.1.1" version = "2.1.1"
@ -2051,15 +2001,6 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "pom"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c2d73a5fe10d458e77534589512104e5aa8ac480aa9ac30b74563274235cce4"
dependencies = [
"bstr",
]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.17" version = "0.2.17"
@ -2072,19 +2013,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" 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]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.66" version = "1.0.66"
@ -3419,12 +3347,6 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "ttf-parser"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ae2f58a822f08abdaf668897e96a5656fe72f5a9ce66422423e8849384872e6"
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.16.0" version = "1.16.0"

View File

@ -21,6 +21,5 @@ log = "0.4.20"
env_logger = "0.10.0" env_logger = "0.10.0"
bardecoder = "0.5.0" bardecoder = "0.5.0"
image = "0.24.7" image = "0.24.7"
printpdf = { version = "0.6.0", features = ["image", "embedded_images"] }

View File

@ -321,7 +321,14 @@ async fn convert_scans_from_data(data: &Vec<(PathBuf, ScanInfo)>) -> Result<(),
match convert_to_pdf(&image_path, &output_path) { match convert_to_pdf(&image_path, &output_path) {
Ok(_) => { 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) => { Err(reason) => {
log::error!("Error converting to pdf: {}", reason); log::error!("Error converting to pdf: {}", reason);