mirror of
https://github.com/qwjyh/xdbm
synced 2024-11-24 07:31: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> {
|
||||
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()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ fn write_storages_list(
|
|||
} else {
|
||||
" "
|
||||
};
|
||||
let path = storage.mount_path(&device, &storages).map_or_else(
|
||||
let path = storage.mount_path(&device).map_or_else(
|
||||
|e| {
|
||||
info!("Not found: {}", e);
|
||||
"".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 {
|
||||
Self::PhysicalStorage(s) => s.mount_path(&device, &storages),
|
||||
Self::SubDirectory(s) => s.mount_path(&device, &storages),
|
||||
Self::Online(s) => s.mount_path(&device, &storages),
|
||||
Self::PhysicalStorage(s) => s.mount_path(&device),
|
||||
Self::SubDirectory(s) => s.mount_path(&device),
|
||||
Self::Online(s) => s.mount_path(&device),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ pub trait StorageExt {
|
|||
|
||||
/// Get mount path of `self` on `device`.
|
||||
/// `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`.
|
||||
fn bound_on_device(
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
//! Manipulate subdirectories of other storages, including directories.
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use anyhow::{Context, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{self, format},
|
||||
path,
|
||||
};
|
||||
use std::{collections::HashMap, fmt, path};
|
||||
|
||||
use crate::devices;
|
||||
use crate::util;
|
||||
|
@ -84,7 +80,7 @@ impl Directory {
|
|||
let parent_mount_path = self
|
||||
.parent(&storages)
|
||||
.context("Can't find parent storage")?
|
||||
.mount_path(&device, &storages)?;
|
||||
.mount_path(&device)?;
|
||||
Ok(parent_mount_path.join(self.relative_path.clone()))
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +98,7 @@ impl StorageExt for Directory {
|
|||
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
|
||||
.local_infos
|
||||
.get(&device.name())
|
||||
|
@ -197,7 +193,7 @@ mod test {
|
|||
storages
|
||||
.get(&"test_name".to_string())
|
||||
.unwrap()
|
||||
.mount_path(&device, &storages)
|
||||
.mount_path(&device)
|
||||
.unwrap(),
|
||||
PathBuf::from("/mnt/sample/subdir")
|
||||
);
|
||||
|
|
|
@ -63,7 +63,6 @@ impl StorageExt for OnlineStorage {
|
|||
fn mount_path(
|
||||
&self,
|
||||
device: &devices::Device,
|
||||
_storages: &Storages,
|
||||
) -> Result<std::path::PathBuf> {
|
||||
Ok(self
|
||||
.local_infos
|
||||
|
|
|
@ -141,7 +141,7 @@ impl StorageExt for PhysicalDrivePartition {
|
|||
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
|
||||
.local_infos
|
||||
.get(&device.name())
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn min_parent_storage<'a>(
|
|||
.list
|
||||
.iter()
|
||||
.filter_map(|(k, storage)| {
|
||||
let storage_path = match storage.mount_path(device, storages) {
|
||||
let storage_path = match storage.mount_path(device) {
|
||||
Ok(path) => path,
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue