remove unnecessary arguments for StorageExt::mount_path

This commit is contained in:
qwjyh 2024-03-17 02:47:34 +09:00
parent ed43d819d6
commit 0e8bd6b4c7
7 changed files with 14 additions and 19 deletions

View file

@ -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()))
}
}

View file

@ -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()

View file

@ -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(

View file

@ -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")
);

View file

@ -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

View file

@ -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())

View file

@ -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,
};