mirror of
https://github.com/qwjyh/xdbm
synced 2024-11-24 15:41:05 +09:00
remove unnecessary arguments for StorageExt::mount_path
This commit is contained in:
parent
ed43d819d6
commit
0e8bd6b4c7
7 changed files with 14 additions and 19 deletions
|
@ -43,7 +43,7 @@ impl BackupTarget {
|
||||||
|
|
||||||
pub fn path(&self, storages: &Storages, device: &Device) -> Result<PathBuf> {
|
pub fn path(&self, storages: &Storages, device: &Device) -> Result<PathBuf> {
|
||||||
let parent = storages.get(&self.storage).unwrap();
|
let parent = storages.get(&self.storage).unwrap();
|
||||||
let parent_path = parent.mount_path(device, storages)?;
|
let parent_path = parent.mount_path(device)?;
|
||||||
Ok(parent_path.join(self.path.clone()))
|
Ok(parent_path.join(self.path.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ fn write_storages_list(
|
||||||
} else {
|
} else {
|
||||||
" "
|
" "
|
||||||
};
|
};
|
||||||
let path = storage.mount_path(&device, &storages).map_or_else(
|
let path = storage.mount_path(&device).map_or_else(
|
||||||
|e| {
|
|e| {
|
||||||
info!("Not found: {}", e);
|
info!("Not found: {}", e);
|
||||||
"".to_string()
|
"".to_string()
|
||||||
|
|
|
@ -68,11 +68,11 @@ impl StorageExt for Storage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mount_path(&self, device: &devices::Device, storages: &Storages) -> Result<path::PathBuf> {
|
fn mount_path(&self, device: &devices::Device) -> Result<path::PathBuf> {
|
||||||
match self {
|
match self {
|
||||||
Self::PhysicalStorage(s) => s.mount_path(&device, &storages),
|
Self::PhysicalStorage(s) => s.mount_path(&device),
|
||||||
Self::SubDirectory(s) => s.mount_path(&device, &storages),
|
Self::SubDirectory(s) => s.mount_path(&device),
|
||||||
Self::Online(s) => s.mount_path(&device, &storages),
|
Self::Online(s) => s.mount_path(&device),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ pub trait StorageExt {
|
||||||
|
|
||||||
/// Get mount path of `self` on `device`.
|
/// Get mount path of `self` on `device`.
|
||||||
/// `storages` is a `HashMap` with key of storage name and value of the storage.
|
/// `storages` is a `HashMap` with key of storage name and value of the storage.
|
||||||
fn mount_path(&self, device: &devices::Device, storages: &Storages) -> Result<path::PathBuf>;
|
fn mount_path(&self, device: &devices::Device) -> Result<path::PathBuf>;
|
||||||
|
|
||||||
/// Add local info of `device` to `self`.
|
/// Add local info of `device` to `self`.
|
||||||
fn bound_on_device(
|
fn bound_on_device(
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
//! Manipulate subdirectories of other storages, including directories.
|
//! Manipulate subdirectories of other storages, including directories.
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{collections::HashMap, fmt, path};
|
||||||
collections::HashMap,
|
|
||||||
fmt::{self, format},
|
|
||||||
path,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::devices;
|
use crate::devices;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
@ -84,7 +80,7 @@ impl Directory {
|
||||||
let parent_mount_path = self
|
let parent_mount_path = self
|
||||||
.parent(&storages)
|
.parent(&storages)
|
||||||
.context("Can't find parent storage")?
|
.context("Can't find parent storage")?
|
||||||
.mount_path(&device, &storages)?;
|
.mount_path(&device)?;
|
||||||
Ok(parent_mount_path.join(self.relative_path.clone()))
|
Ok(parent_mount_path.join(self.relative_path.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +98,7 @@ impl StorageExt for Directory {
|
||||||
self.local_infos.get(&device.name())
|
self.local_infos.get(&device.name())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mount_path(&self, device: &devices::Device, storages: &Storages) -> Result<path::PathBuf> {
|
fn mount_path(&self, device: &devices::Device) -> Result<path::PathBuf> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.local_infos
|
.local_infos
|
||||||
.get(&device.name())
|
.get(&device.name())
|
||||||
|
@ -197,7 +193,7 @@ mod test {
|
||||||
storages
|
storages
|
||||||
.get(&"test_name".to_string())
|
.get(&"test_name".to_string())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.mount_path(&device, &storages)
|
.mount_path(&device)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
PathBuf::from("/mnt/sample/subdir")
|
PathBuf::from("/mnt/sample/subdir")
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,7 +63,6 @@ impl StorageExt for OnlineStorage {
|
||||||
fn mount_path(
|
fn mount_path(
|
||||||
&self,
|
&self,
|
||||||
device: &devices::Device,
|
device: &devices::Device,
|
||||||
_storages: &Storages,
|
|
||||||
) -> Result<std::path::PathBuf> {
|
) -> Result<std::path::PathBuf> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.local_infos
|
.local_infos
|
||||||
|
|
|
@ -141,7 +141,7 @@ impl StorageExt for PhysicalDrivePartition {
|
||||||
self.local_infos.get(&device.name())
|
self.local_infos.get(&device.name())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mount_path(&self, device: &devices::Device, _: &Storages) -> Result<path::PathBuf> {
|
fn mount_path(&self, device: &devices::Device) -> Result<path::PathBuf> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.local_infos
|
.local_infos
|
||||||
.get(&device.name())
|
.get(&device.name())
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub fn min_parent_storage<'a>(
|
||||||
.list
|
.list
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(k, storage)| {
|
.filter_map(|(k, storage)| {
|
||||||
let storage_path = match storage.mount_path(device, storages) {
|
let storage_path = match storage.mount_path(device) {
|
||||||
Ok(path) => path,
|
Ok(path) => path,
|
||||||
Err(_) => return None,
|
Err(_) => return None,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue