Use & instead of calling .as_path()
This commit is contained in:
parent
bacaae7878
commit
e5f7e5f5f1
3 changed files with 11 additions and 17 deletions
|
|
@ -167,7 +167,7 @@ fn create_etc_static_link(
|
|||
) -> (EtcTree, Result<()>) {
|
||||
let static_path = etc_dir.join(static_dir_name);
|
||||
let (new_state, status) = create_dir_recursively(static_path.parent().unwrap(), state);
|
||||
match status.and_then(|_| create_store_link(store_path, static_path.as_path())) {
|
||||
match status.and_then(|_| create_store_link(store_path, &static_path)) {
|
||||
Ok(_) => (new_state.register_managed_entry(&static_path), Ok(())),
|
||||
e => (new_state, e),
|
||||
}
|
||||
|
|
@ -179,12 +179,11 @@ fn create_etc_link(link_target: &OsStr, etc_dir: &Path, state: EtcTree) -> (EtcT
|
|||
let (new_state, status) = create_dir_recursively(link_path.parent().unwrap(), state);
|
||||
match status.and_then(|_| {
|
||||
create_link(
|
||||
Path::new(".")
|
||||
&Path::new(".")
|
||||
.join(SYSTEM_MANAGER_STATIC_NAME)
|
||||
.join("etc")
|
||||
.join(link_target)
|
||||
.as_path(),
|
||||
link_path.as_path(),
|
||||
.join(link_target),
|
||||
&link_path,
|
||||
)
|
||||
}) {
|
||||
Ok(_) => (new_state.register_managed_entry(&link_path), Ok(())),
|
||||
|
|
@ -208,16 +207,11 @@ fn create_etc_entry(
|
|||
)
|
||||
}
|
||||
} else {
|
||||
let target_path = etc_dir.join(entry.target.as_path());
|
||||
let target_path = etc_dir.join(&entry.target);
|
||||
let (new_state, status) = create_dir_recursively(target_path.parent().unwrap(), state);
|
||||
match status.and_then(|_| {
|
||||
copy_file(
|
||||
entry
|
||||
.source
|
||||
.store_path
|
||||
.join("etc")
|
||||
.join(&entry.target)
|
||||
.as_path(),
|
||||
&entry.source.store_path.join("etc").join(&entry.target),
|
||||
&target_path,
|
||||
&entry.mode,
|
||||
old_state,
|
||||
|
|
@ -244,7 +238,7 @@ fn create_dir_recursively(dir: &Path, state: EtcTree) -> (EtcTree, Result<()>) {
|
|||
let new_path = path.join(dir);
|
||||
if !new_path.exists() {
|
||||
log::debug!("Creating path: {}", new_path.display());
|
||||
match dirbuilder.create(new_path.as_path()) {
|
||||
match dirbuilder.create(&new_path) {
|
||||
Ok(_) => {
|
||||
let new_state = state.register_managed_entry(&new_path);
|
||||
Continue((new_state, new_path, Ok(())))
|
||||
|
|
@ -287,7 +281,7 @@ fn etc_dir(ephemeral: bool) -> PathBuf {
|
|||
if ephemeral {
|
||||
Path::new("/run").join("etc")
|
||||
} else {
|
||||
Path::new("/etc").to_path_buf()
|
||||
PathBuf::from("/etc")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ mod tests {
|
|||
.register_managed_entry(&PathBuf::from("/").join("foo5").join("bar"));
|
||||
let new_tree = tree1.update_state(tree2, &|path, _status| {
|
||||
println!("Deactivating path: {}", path.display());
|
||||
path != PathBuf::from("/").join("foo5").join("bar").as_path()
|
||||
*path != PathBuf::from("/").join("foo5").join("bar")
|
||||
});
|
||||
assert_eq!(
|
||||
new_tree.unwrap().nested.keys().sorted().collect::<Vec<_>>(),
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ pub fn deactivate() -> Result<()> {
|
|||
fn unlink_services(services: &LinkedServices) -> Result<()> {
|
||||
services
|
||||
.values()
|
||||
.try_for_each(|linked_service| remove_link(linked_service.linked_path().as_path()))
|
||||
.try_for_each(|linked_service| remove_link(&linked_service.linked_path()))
|
||||
}
|
||||
|
||||
fn link_services(services: Services, ephemeral: bool) -> Result<LinkedServices> {
|
||||
|
|
@ -129,7 +129,7 @@ fn link_services(services: Services, ephemeral: bool) -> Result<LinkedServices>
|
|||
HashMap::with_capacity(services.len()),
|
||||
|mut linked_services, (name, service_config)| {
|
||||
let linked_path = systemd_system_dir.join(name);
|
||||
match create_store_link(&service_config.store_path, linked_path.as_path()) {
|
||||
match create_store_link(&service_config.store_path, &linked_path) {
|
||||
Ok(_) => {
|
||||
linked_services.insert(
|
||||
name.to_owned(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue