various: fix trailing commas and import ordering
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia48ceb56b9b1ce50ee01ff38d14f740c6a6a6964
This commit is contained in:
parent
f396ce82af
commit
b5fb382ac0
2 changed files with 44 additions and 22 deletions
|
|
@ -964,16 +964,19 @@ impl Config {
|
|||
|
||||
/// Ensure all directories needed by this config exist and are writable.
|
||||
pub fn ensure_dirs(&self) -> crate::error::Result<()> {
|
||||
if let Some(ref sqlite) = self.storage.sqlite
|
||||
&& let Some(parent) = sqlite.path.parent()
|
||||
{
|
||||
std::fs::create_dir_all(parent)?;
|
||||
let metadata = std::fs::metadata(parent)?;
|
||||
if metadata.permissions().readonly() {
|
||||
return Err(crate::error::PinakesError::Config(format!(
|
||||
"directory is not writable: {}",
|
||||
parent.display()
|
||||
)));
|
||||
if let Some(ref sqlite) = self.storage.sqlite {
|
||||
if let Some(parent) = sqlite.path.parent() {
|
||||
// Skip if parent is empty string (happens with bare filenames like "pinakes.db")
|
||||
if !parent.as_os_str().is_empty() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
let metadata = std::fs::metadata(parent)?;
|
||||
if metadata.permissions().readonly() {
|
||||
return Err(crate::error::PinakesError::Config(format!(
|
||||
"directory is not writable: {}",
|
||||
parent.display()
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue