update storage bind

This commit is contained in:
qwjyh 2024-03-13 05:36:19 +09:00
parent d212d32430
commit 498dd2db9b
3 changed files with 18 additions and 16 deletions

View file

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

View file

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

View file

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