summaryrefslogtreecommitdiff
path: root/src/files.rs
diff options
context:
space:
mode:
authorjakka <jakkadoujin@gmail.com>2025-07-07 14:01:46 +0300
committerjakka <jakkadoujin@gmail.com>2025-07-07 14:01:46 +0300
commit9b459adeafffcecdcb19e60806272a466e02b184 (patch)
tree0029a4abfbca5f60cddbce2ad63dc685f70f0176 /src/files.rs
parentfccc22cd4a4a84211d8b61cf561d0f4463f500f1 (diff)
added better mutex handlingv0.2.3
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/files.rs b/src/files.rs
index 9793243..d3f68b4 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -149,21 +149,24 @@ pub fn reencode_files(conn: Connection, handler: Arc<AtomicBool>) -> Result<()>
files.par_iter().for_each(|file| {
if handler.load(Ordering::SeqCst) {
- let conn = match lock.lock() {
- Ok(conn) => conn,
- Err(_) => {
- eprintln!("Lock poisoned on file:\t{}", file.to_string_lossy());
- return;
- }
- };
- if let Err(error) = handle_encode(file) {
- eprintln!("{}", FileError::new(file, error));
- } else {
- if let Err(error) = conn.update_file(file) {
- eprintln!("{}", FileError::new(file, error));
+ let newhandler = handler.clone();
+ match handle_encode(file, newhandler) {
+ Err(error) => eprintln!("{}", FileError::new(file, error)),
+ Ok(false) => {
+ let conn = match lock.lock() {
+ Ok(conn) => conn,
+ Err(_) => {
+ eprintln!("Lock poisoned on file:\t{}", file.to_string_lossy());
+ return;
+ }
+ };
+ if let Err(error) = conn.update_file(file) {
+ eprintln!("{}", FileError::new(file, error));
+ }
+ #[cfg(not(test))]
+ bar.inc(1)
}
- #[cfg(not(test))]
- bar.inc(1)
+ Ok(true) => {}
}
}
});