1
0
Fork 0
This commit is contained in:
Malte Brandy 2018-07-19 19:51:05 +02:00
parent 813d2d6367
commit e57568feb8
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
2 changed files with 94 additions and 77 deletions

View file

@ -154,7 +154,10 @@ impl GeneratedTask for Task {
fn check_ignores(cache: &TaskCache) -> Result<()> { fn check_ignores(cache: &TaskCache) -> Result<()> {
if *cache.ignore() != vec![TS::Deleted] { if *cache.ignore() != vec![TS::Deleted] {
return Err("Don't use generate with a TaskCache with ignores other than 'TaskStatus::Deleted'".into()); return Err(
"Don't use generate with a TaskCache with ignores other than 'TaskStatus::Deleted'"
.into(),
);
}; };
Ok(()) Ok(())
} }
@ -249,14 +252,35 @@ fn process_orphans(
orphans: HashMap<String, HashMap<String, Uuid>>, orphans: HashMap<String, HashMap<String, Uuid>>,
) -> Result<()> { ) -> Result<()> {
for uuid in orphans.values().flat_map(HashMap::values) { for uuid in orphans.values().flat_map(HashMap::values) {
match cache.get(uuid).chain_err(|| "Cache miss for orphan")?.gen_orphan() { match cache
O::CompleteOrphan => if *cache.get(uuid).chain_err(|| "Cache miss for orphan")?.status() != TS::Completed { .get(uuid)
*cache.get_mut(uuid).chain_err(|| "Cache miss for orphan")?.status_mut() = TS::Completed; .chain_err(|| "Cache miss for orphan")?
.gen_orphan() {
O::CompleteOrphan => {
if *cache
.get(uuid)
.chain_err(|| "Cache miss for orphan")?
.status() != TS::Completed
{
*cache
.get_mut(uuid)
.chain_err(|| "Cache miss for orphan")?
.status_mut() = TS::Completed;
} }
O::DeleteOrphan => if *cache.get(uuid).chain_err(|| "Cache miss for orphan")?.status() != TS::Deleted {
*cache.get_mut(uuid).chain_err(|| "Cache miss for orphan")?.status_mut() = TS::Deleted;
} }
_ => () O::DeleteOrphan => {
if *cache
.get(uuid)
.chain_err(|| "Cache miss for orphan")?
.status() != TS::Deleted
{
*cache
.get_mut(uuid)
.chain_err(|| "Cache miss for orphan")?
.status_mut() = TS::Deleted;
}
}
_ => (),
} }
} }
Ok(()) Ok(())
@ -302,8 +326,7 @@ where
orphans orphans
.entry(name.clone()) .entry(name.clone())
.or_insert_with(|| { .or_insert_with(|| {
self self.filter(|t| t.gen_name() == Some(name))
.filter(|t| t.gen_name() == Some(name))
.filter_map(|t| t.gen_id().map(|id| (id.clone(), t.uuid().clone()))) .filter_map(|t| t.gen_id().map(|id| (id.clone(), t.uuid().clone())))
.collect() .collect()
}) })

View file

@ -1,17 +1,11 @@
use dialog::{ use dialog::DialogProvider;
DialogProvider, use dialog::errors::{Error, ErrorKind as EK};
errors::{ use dialog::rofi::RofiDialogProvider;
Error,
ErrorKind as EK},
rofi::RofiDialogProvider
};
use std::{ use std::process::Command as StdCommand;
process::Command as StdCommand, use std::os::unix::process::CommandExt;
os::unix::process::CommandExt, use std::env::var;
env::var, use std::rc::Rc;
rc::Rc
};
use error::{Result, ResultExt}; use error::{Result, ResultExt};