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