(no commit message provided)

This commit is contained in:
Andrew Phillips
2025-05-13 08:16:47 -03:00
committed by Andrew Phillips (aider)
parent 9ba3a31e95
commit 7db2a2ab75
7 changed files with 17 additions and 17 deletions

View File

@@ -70,7 +70,7 @@ pub trait CompressionEngine {
let args = ["-bE", "-"];
let process = Command::new(program)
.args(args.clone())
.args(args)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
@@ -101,7 +101,7 @@ pub trait CompressionEngine {
break;
}
size = size + n;
size += n;
}
Ok(size)

View File

@@ -121,7 +121,7 @@ pub fn query_upsert_meta(conn: &Connection, meta: Meta) -> Result<()> {
pub fn store_meta(conn: &Connection, meta: Meta) -> Result<()> {
debug!("DB: Storing meta: {:?}", meta);
if meta.value.eq("") {
if meta.value.is_empty() {
query_delete_meta(conn, meta)?;
} else {
query_upsert_meta(conn, meta)?;

View File

@@ -1,4 +1,4 @@
use anyhow::{anyhow, Context, Result};
use anyhow::Result;
use std::io;
use lazy_static::lazy_static;

View File

@@ -71,7 +71,7 @@ pub fn mode_list(
let mut title_row = row!();
for column in list_format.clone() {
let mut column_format = column.split(":").into_iter();
let mut column_format = column.split(":");
let column_name = column_format.next().expect("Unable to parse column name");
let column_type = ColumnType::from_str(column_name)
.map_err(|_| anyhow!("Unknown column {:?}", column_name))?;
@@ -98,10 +98,10 @@ pub fn mode_list(
let mut table_row = Row::new(vec![]);
for column in list_format.clone() {
let mut column_format = column.split(":").into_iter();
let mut column_format = column.split(":");
let column_name = column_format.next().expect("Unable to parse column name");
let column_type = ColumnType::from_str(column_name)
.expect(format!("Unknown column {:?}", column_name).as_str());
.unwrap_or_else(|_| panic!("Unknown column {:?}", column_name));
let mut meta_name: Option<&str> = None;
if column_type == ColumnType::Meta {
@@ -145,7 +145,7 @@ pub fn mode_list(
ColumnType::FileSize => match item_path.metadata() {
Ok(metadata) => Cell::new_align(
&size_column(
metadata.len() as u64,
metadata.len(),
args.options.human_readable,
column_width,
),

View File

@@ -12,6 +12,7 @@ use rusqlite::Connection;
use crate::db::{self};
use crate::digest_engine::{get_engine, DigestEngine, DigestType};
use crate::compression_engine::{get_engine, CompressionEngine, CompressionType};
use crate::modes::common::get_meta_from_env;
use chrono::Utc;
@@ -49,8 +50,7 @@ pub fn mode_save(
use gethostname::gethostname;
use std::io::Write;
let compression_type_opt =
crate::compression_engine::CompressionType::from_str(&compression_name);
let compression_type_opt = CompressionType::from_str(&compression_name);
if compression_type_opt.is_err() {
cmd.error(
ErrorKind::InvalidValue,
@@ -73,7 +73,7 @@ pub fn mode_save(
compression: compression_type.to_string(),
};
let id = db::insert_item(&conn, item.clone())?;
let id = db::insert_item(conn, item.clone())?;
item.id = Some(id);
debug!("MAIN: Added item {:?}", item.clone());
@@ -100,7 +100,7 @@ pub fn mode_save(
}
}
db::set_item_tags(&conn, item.clone(), tags)?;
db::set_item_tags(conn, item.clone(), tags)?;
let mut item_meta: HashMap<String, String> = get_meta_from_env();
@@ -121,7 +121,7 @@ pub fn mode_save(
name: kv.0.to_string(),
value: kv.1.to_string(),
};
db::store_meta(&conn, meta)?;
db::store_meta(conn, meta)?;
}
let mut item_path = data_path.clone();
@@ -168,7 +168,7 @@ pub fn mode_save(
let digest = digest_engine.finalize()?;
debug!("DIGEST: {}", digest);
db::update_item(&conn, item.clone())?;
db::update_item(conn, item.clone())?;
Ok(())
}

View File

@@ -100,7 +100,7 @@ pub fn mode_status(
true => Cell::new("Yes").with_style(Attr::ForegroundColor(color::GREEN)),
false => Cell::new("No"),
},
match compression_program.program.eq("") {
match compression_program.program.is_empty() {
true => {
Cell::new("<INTERNAL>").with_style(Attr::ForegroundColor(color::BRIGHT_BLACK))
}

View File

@@ -51,7 +51,7 @@ pub fn mode_update(
.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())?;
db::update_item(conn, item.clone())?;
} else {
debug!(
"MAIN: Unable to update size of item due to missing file {:?}",
@@ -60,7 +60,7 @@ pub fn mode_update(
}
}
if args.item.meta.len() > 0 {
if !args.item.meta.is_empty() {
debug!("MAIN: Updating item meta");
for kv in args.item.meta.iter() {
let meta = db::Meta {