style: reorder imports and reformat code for consistency

This commit is contained in:
Andrew Phillips
2025-05-10 10:06:33 -03:00
committed by Andrew Phillips (aider)
parent c936326ac3
commit 9feec61759
13 changed files with 492 additions and 356 deletions

View File

@@ -3,10 +3,10 @@ use std::path::PathBuf;
use std::str::FromStr;
use crate::db;
use clap::Command;
use clap::error::ErrorKind;
use log::{debug, info};
use crate::CompressionType;
use clap::error::ErrorKind;
use clap::Command;
use log::{debug, info};
use rusqlite::Connection;
pub fn mode_update(
@@ -18,7 +18,11 @@ pub fn mode_update(
data_path: PathBuf,
) -> Result<()> {
if ids.is_empty() {
cmd.error(ErrorKind::InvalidValue, "No ID given, you must supply exactly one ID when using --update").exit();
cmd.error(
ErrorKind::InvalidValue,
"No ID given, you must supply exactly one ID when using --update",
)
.exit();
} else if ids.len() > 1 {
cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID or atleast one tag when using --update").exit();
}
@@ -29,7 +33,7 @@ pub fn mode_update(
let mut item = item_maybe.expect("Unable to find item in database");
debug!("MAIN: Found item {:?}", item);
if ! tags.is_empty() {
if !tags.is_empty() {
debug!("MAIN: Updating item tags");
db::set_item_tags(conn, item.clone(), tags)?;
}
@@ -43,12 +47,16 @@ pub fn mode_update(
if item_file_metadata.is_ok() {
debug!("MAIN: Updating stream size of {:?}", item_path);
let compression_type = CompressionType::from_str(&item.compression)?;
let compression_engine = crate::compression::get_engine(compression_type).expect("Unable to get compression engine");
let compression_engine = crate::compression::get_engine(compression_type)
.expect("Unable to get compression engine");
let size = compression_engine.size(item_path)? as i64;
item.size = Some(size);
db::update_item(&conn, item.clone())?;
} else {
debug!("MAIN: Unable to update size of item due to missing file {:?}", item_path);
debug!(
"MAIN: Unable to update size of item due to missing file {:?}",
item_path
);
}
}
@@ -58,7 +66,7 @@ pub fn mode_update(
let meta = db::Meta {
id: item.id.unwrap(),
name: kv.key.to_string(),
value: kv.value.to_string()
value: kv.value.to_string(),
};
db::store_meta(conn, meta)?;
}