diff options
-rw-r--r-- | src/database/file/mod.rs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/database/file/mod.rs b/src/database/file/mod.rs index 64d9564..031527e 100644 --- a/src/database/file/mod.rs +++ b/src/database/file/mod.rs @@ -171,12 +171,11 @@ fn modify_post(post: &serde_json::Value, update: &serde_json::Value) -> Result<s } for (k, v) in remove_values { let k = &k; - let props; - if k == "children" { - props = &mut post; + let props = if k == "children" { + &mut post } else { - props = &mut post["properties"]; - } + &mut post["properties"] + }; v.iter().for_each(|v| { if let Some(vec) = props[k].as_array_mut() { if let Some(index) = vec.iter().position(|w| w == v) { @@ -186,12 +185,11 @@ fn modify_post(post: &serde_json::Value, update: &serde_json::Value) -> Result<s }); } for (k, v) in add_keys { - let props; - if k == "children" { - props = &mut post; + let props = if k == "children" { + &mut post } else { - props = &mut post["properties"]; - } + &mut post["properties"] + }; let k = &k; if let Some(prop) = props[k].as_array_mut() { if k == "children" { @@ -357,10 +355,7 @@ impl Storage for FileStorage { })?; let relative = path_relative_from(&orig, basedir).unwrap(); println!("{:?} - {:?} = {:?}", &orig, &basedir, &relative); - #[cfg(unix)] tokio::fs::symlink(relative, link).await?; - #[cfg(not(unix))] - compile_error!("Don't know how to create symlinks on your OS"); } } } @@ -603,7 +598,9 @@ impl Storage for FileStorage { } Err(err) => if err.kind() == IOErrorKind::NotFound { HashMap::default() - } else { Err(err)? } + } else { + return Err(err.into()) + } }; settings.insert(setting, value); tempfile.write_all(serde_json::to_string(&settings)?.as_bytes()).await?; |