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<()> {
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(())
}
@ -249,14 +252,35 @@ fn process_orphans(
orphans: HashMap<String, HashMap<String, Uuid>>,
) -> Result<()> {
for uuid in orphans.values().flat_map(HashMap::values) {
match cache.get(uuid).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;
match cache
.get(uuid)
.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(())
@ -302,8 +326,7 @@ where
orphans
.entry(name.clone())
.or_insert_with(|| {
self
.filter(|t| t.gen_name() == Some(name))
self.filter(|t| t.gen_name() == Some(name))
.filter_map(|t| t.gen_id().map(|id| (id.clone(), t.uuid().clone())))
.collect()
})

View file

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