From 4c95e403e9f326e08e3dd7416466b23b2a0627c6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 2 Jan 2016 16:09:44 +0100 Subject: [PATCH 1/2] Add information output to BM-remove --- src/module/bm/mod.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 8ce411ff..0c693f0f 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -143,15 +143,21 @@ impl<'a> BM<'a> { let f = file.deref().borrow(); self.rt.store().remove(f.id().clone()) }) - .all(|x| x); + .fold((0, 0), |acc, succeeded| { + let (worked, failed) = acc; + if succeeded { + (worked + 1, failed) + } else { + (worked, failed + 1) + } + }); - if result { - info!("Removing succeeded"); - } else { - info!("Removing failed"); - } + let (worked, failed) = result; - return result; + info!("Removing succeeded for {} files", worked); + info!("Removing failed for {} files", failed); + + return failed == 0; } /** From bdfaac0c76530901d606e6510568effa307d5dc5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 2 Jan 2016 16:15:30 +0100 Subject: [PATCH 2/2] Add info output to BM-add command --- src/module/bm/mod.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 0c693f0f..1fc3ac03 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -58,11 +58,28 @@ impl<'a> BM<'a> { debug!(" tags = '{:?}'", tags); let header = build_header(url, tags); - let fileid = self.rt.store().new_file_with_header(self, header); - self.rt.store().load(self, &parser, &fileid).and_then(|file| { - info!("Created file in memory: {}", fileid); - Some(self.rt.store().persist(&parser, file)) - }).unwrap_or(false) + let fileid = self.rt + .store() + .new_file_with_header(self, header); + + let result = self.rt + .store() + .load(self, &parser, &fileid) + .map(|file| { + info!("Created file in memory: {}", fileid); + self.rt + .store() + .persist(&parser, file) + }) + .unwrap_or(false); + + if result { + info!("Adding worked"); + } else { + info!("Adding failed"); + } + + result } fn validate_url(&self, url: &String, parser: &Parser) -> bool