Make home directory optional.
This commit is contained in:
parent
b8dba63d39
commit
5414ceec07
@ -153,7 +153,8 @@ pub fn generate(
|
||||
|
||||
rev_cert
|
||||
} else if on_keystore {
|
||||
let dir = sq.home.data_dir(sequoia_directories::Component::Other(
|
||||
if let Some(home) = &sq.home {
|
||||
let dir = home.data_dir(sequoia_directories::Component::Other(
|
||||
"revocation-certificates".into()));
|
||||
std::fs::create_dir_all(&dir)
|
||||
.with_context(|| {
|
||||
@ -164,6 +165,12 @@ pub fn generate(
|
||||
FileOrStdout::new(
|
||||
Some(dir.join(format!("{}-revocation.pgp",
|
||||
cert.fingerprint()))))
|
||||
} else {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Missing arguments: --rev-cert is mandatory if --home=none is \
|
||||
given."
|
||||
));
|
||||
}
|
||||
} else {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Missing arguments: --rev-cert is mandatory if --output is \
|
||||
|
@ -447,7 +447,10 @@ pub fn list(sq: Sq, mut cmd: cli::key::list::Command) -> Result<()> {
|
||||
let mut hint = sq.hint(format_args!(
|
||||
"There are no secret keys."));
|
||||
|
||||
if sq.key_store_path.is_some() || ! sq.home.is_default_location() {
|
||||
if sq.key_store_path.is_some()
|
||||
|| ! sq.home.as_ref()
|
||||
.map(|h| h.is_default_location()).unwrap_or(false)
|
||||
{
|
||||
hint = hint.hint(format_args!(
|
||||
"The non-default key store location {} is selected \
|
||||
using the `{}` option. Consider using the default \
|
||||
|
@ -301,14 +301,14 @@ fn real_main() -> Result<()> {
|
||||
time_is_now,
|
||||
policy_as_of,
|
||||
policy: &policy,
|
||||
home: if let Some(p) = c.home.as_ref().and_then(|a| a.path()) {
|
||||
home: Some(if let Some(p) = c.home.as_ref().and_then(|a| a.path()) {
|
||||
sequoia_directories::Home::new(p)?
|
||||
} else {
|
||||
sequoia_directories::Home::default()
|
||||
.ok_or(anyhow::anyhow!("no default SEQUOIA_HOME \
|
||||
on this platform"))?
|
||||
.clone()
|
||||
},
|
||||
}),
|
||||
no_rw_cert_store: c.no_cert_store,
|
||||
cert_store_path: c.cert_store.as_ref().and_then(|a| a.path()),
|
||||
keyrings: c.keyring.clone(),
|
||||
|
@ -104,7 +104,7 @@ pub struct Sq<'store, 'rstore>
|
||||
pub time_is_now: bool,
|
||||
pub policy: &'rstore P<'rstore>,
|
||||
pub policy_as_of: SystemTime,
|
||||
pub home: sequoia_directories::Home,
|
||||
pub home: Option<sequoia_directories::Home>,
|
||||
// --no-cert-store
|
||||
#[deprecated]
|
||||
pub no_rw_cert_store: bool,
|
||||
@ -161,7 +161,8 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
|
||||
} else if let Ok(path) = std::env::var("PGP_CERT_D") {
|
||||
Some(PathBuf::from(path))
|
||||
} else {
|
||||
Some(self.home.data_dir(sequoia_directories::Component::CertD))
|
||||
self.home.as_ref()
|
||||
.map(|h| h.data_dir(sequoia_directories::Component::CertD))
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,7 +367,8 @@ impl<'store: 'rstore, 'rstore> Sq<'store, 'rstore> {
|
||||
} else if let Some(dir) = self.key_store_path.as_ref() {
|
||||
Ok(Some(dir.clone()))
|
||||
} else {
|
||||
Ok(Some(self.home.data_dir(sequoia_directories::Component::Keystore)))
|
||||
Ok(self.home.as_ref()
|
||||
.map(|h| h.data_dir(sequoia_directories::Component::Keystore)))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user