mirror of
https://github.com/qwjyh/xdbm
synced 2024-11-22 06:40:12 +09:00
update storage bind
This commit is contained in:
parent
d212d32430
commit
498dd2db9b
3 changed files with 18 additions and 16 deletions
|
@ -9,6 +9,7 @@
|
|||
- [x] storage add online
|
||||
- [ ] storage add directory
|
||||
- [ ] storage list
|
||||
- [x] update storage bind command
|
||||
- [ ] add storage remove command
|
||||
- [ ] add sync subcommand
|
||||
- [ ] add check subcommand
|
||||
|
|
|
@ -259,15 +259,22 @@ pub(crate) fn cmd_storage_bind(
|
|||
.list
|
||||
.get_mut(&storage_name)
|
||||
.context(format!("No storage has name {}", storage_name))?;
|
||||
let old_alias = storage
|
||||
.local_info(&device)
|
||||
.context(format!("Failed to get LocalInfo for {}", storage.name()))?
|
||||
.alias()
|
||||
.clone();
|
||||
if let Some(localinfo) = storage.local_info(&device) {
|
||||
return Err(anyhow!(
|
||||
"The storage {} is already bounded on this device as {}",
|
||||
storage.name(),
|
||||
localinfo.alias(),
|
||||
));
|
||||
}
|
||||
// TODO: get mount path for directory automatically?
|
||||
storage.bound_on_device(new_alias, mount_point, &device)?;
|
||||
storage.bound_on_device(new_alias.clone(), mount_point, &device)?;
|
||||
// trace!("storage: {}", &storage);
|
||||
format!("{} to {}", old_alias, storage.name())
|
||||
format!(
|
||||
"{} is now {} on the device {}",
|
||||
storage.name(),
|
||||
new_alias,
|
||||
device.name()
|
||||
)
|
||||
};
|
||||
trace!("bound new system name to the storage");
|
||||
trace!("storages: {:#?}", storages);
|
||||
|
@ -277,15 +284,9 @@ pub(crate) fn cmd_storage_bind(
|
|||
add_and_commit(
|
||||
&repo,
|
||||
&Path::new(storages::STORAGESFILE),
|
||||
&format!(
|
||||
"Bound new storage name to physical drive ({})",
|
||||
commit_comment
|
||||
),
|
||||
&format!("Bound new storage name to storage ({})", commit_comment),
|
||||
)?;
|
||||
println!(
|
||||
"Bound new storage name to physical drive ({})",
|
||||
commit_comment
|
||||
);
|
||||
println!("Bound new storage name to storage ({})", commit_comment);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ fn main() -> Result<()> {
|
|||
match storage.command {
|
||||
StorageCommands::Add(storageargs) => {
|
||||
cmd_storage::cmd_storage_add(storageargs.command, repo, &config_dir)?
|
||||
},
|
||||
}
|
||||
StorageCommands::List { long } => cmd_storage::cmd_storage_list(&config_dir, long)?,
|
||||
StorageCommands::Bind {
|
||||
storage: storage_name,
|
||||
|
|
Loading…
Reference in a new issue