(no commit message provided)
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
9ba3a31e95
commit
7db2a2ab75
@@ -70,7 +70,7 @@ pub trait CompressionEngine {
|
|||||||
let args = ["-bE", "-"];
|
let args = ["-bE", "-"];
|
||||||
|
|
||||||
let process = Command::new(program)
|
let process = Command::new(program)
|
||||||
.args(args.clone())
|
.args(args)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
@@ -101,7 +101,7 @@ pub trait CompressionEngine {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = size + n;
|
size += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(size)
|
Ok(size)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ pub fn query_upsert_meta(conn: &Connection, meta: Meta) -> Result<()> {
|
|||||||
|
|
||||||
pub fn store_meta(conn: &Connection, meta: Meta) -> Result<()> {
|
pub fn store_meta(conn: &Connection, meta: Meta) -> Result<()> {
|
||||||
debug!("DB: Storing meta: {:?}", meta);
|
debug!("DB: Storing meta: {:?}", meta);
|
||||||
if meta.value.eq("") {
|
if meta.value.is_empty() {
|
||||||
query_delete_meta(conn, meta)?;
|
query_delete_meta(conn, meta)?;
|
||||||
} else {
|
} else {
|
||||||
query_upsert_meta(conn, meta)?;
|
query_upsert_meta(conn, meta)?;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::Result;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ pub fn mode_list(
|
|||||||
let mut title_row = row!();
|
let mut title_row = row!();
|
||||||
|
|
||||||
for column in list_format.clone() {
|
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_name = column_format.next().expect("Unable to parse column name");
|
||||||
let column_type = ColumnType::from_str(column_name)
|
let column_type = ColumnType::from_str(column_name)
|
||||||
.map_err(|_| anyhow!("Unknown column {:?}", column_name))?;
|
.map_err(|_| anyhow!("Unknown column {:?}", column_name))?;
|
||||||
@@ -98,10 +98,10 @@ pub fn mode_list(
|
|||||||
let mut table_row = Row::new(vec![]);
|
let mut table_row = Row::new(vec![]);
|
||||||
|
|
||||||
for column in list_format.clone() {
|
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_name = column_format.next().expect("Unable to parse column name");
|
||||||
let column_type = ColumnType::from_str(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;
|
let mut meta_name: Option<&str> = None;
|
||||||
|
|
||||||
if column_type == ColumnType::Meta {
|
if column_type == ColumnType::Meta {
|
||||||
@@ -145,7 +145,7 @@ pub fn mode_list(
|
|||||||
ColumnType::FileSize => match item_path.metadata() {
|
ColumnType::FileSize => match item_path.metadata() {
|
||||||
Ok(metadata) => Cell::new_align(
|
Ok(metadata) => Cell::new_align(
|
||||||
&size_column(
|
&size_column(
|
||||||
metadata.len() as u64,
|
metadata.len(),
|
||||||
args.options.human_readable,
|
args.options.human_readable,
|
||||||
column_width,
|
column_width,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use rusqlite::Connection;
|
|||||||
|
|
||||||
use crate::db::{self};
|
use crate::db::{self};
|
||||||
use crate::digest_engine::{get_engine, DigestEngine, DigestType};
|
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 crate::modes::common::get_meta_from_env;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
|
|
||||||
@@ -49,8 +50,7 @@ pub fn mode_save(
|
|||||||
|
|
||||||
use gethostname::gethostname;
|
use gethostname::gethostname;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
let compression_type_opt =
|
let compression_type_opt = CompressionType::from_str(&compression_name);
|
||||||
crate::compression_engine::CompressionType::from_str(&compression_name);
|
|
||||||
if compression_type_opt.is_err() {
|
if compression_type_opt.is_err() {
|
||||||
cmd.error(
|
cmd.error(
|
||||||
ErrorKind::InvalidValue,
|
ErrorKind::InvalidValue,
|
||||||
@@ -73,7 +73,7 @@ pub fn mode_save(
|
|||||||
compression: compression_type.to_string(),
|
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);
|
item.id = Some(id);
|
||||||
debug!("MAIN: Added item {:?}", item.clone());
|
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();
|
let mut item_meta: HashMap<String, String> = get_meta_from_env();
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ pub fn mode_save(
|
|||||||
name: kv.0.to_string(),
|
name: kv.0.to_string(),
|
||||||
value: kv.1.to_string(),
|
value: kv.1.to_string(),
|
||||||
};
|
};
|
||||||
db::store_meta(&conn, meta)?;
|
db::store_meta(conn, meta)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut item_path = data_path.clone();
|
let mut item_path = data_path.clone();
|
||||||
@@ -168,7 +168,7 @@ pub fn mode_save(
|
|||||||
let digest = digest_engine.finalize()?;
|
let digest = digest_engine.finalize()?;
|
||||||
debug!("DIGEST: {}", digest);
|
debug!("DIGEST: {}", digest);
|
||||||
|
|
||||||
db::update_item(&conn, item.clone())?;
|
db::update_item(conn, item.clone())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ pub fn mode_status(
|
|||||||
true => Cell::new("Yes").with_style(Attr::ForegroundColor(color::GREEN)),
|
true => Cell::new("Yes").with_style(Attr::ForegroundColor(color::GREEN)),
|
||||||
false => Cell::new("No"),
|
false => Cell::new("No"),
|
||||||
},
|
},
|
||||||
match compression_program.program.eq("") {
|
match compression_program.program.is_empty() {
|
||||||
true => {
|
true => {
|
||||||
Cell::new("<INTERNAL>").with_style(Attr::ForegroundColor(color::BRIGHT_BLACK))
|
Cell::new("<INTERNAL>").with_style(Attr::ForegroundColor(color::BRIGHT_BLACK))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub fn mode_update(
|
|||||||
.expect("Unable to get compression engine");
|
.expect("Unable to get compression engine");
|
||||||
let size = compression_engine.size(item_path)? as i64;
|
let size = compression_engine.size(item_path)? as i64;
|
||||||
item.size = Some(size);
|
item.size = Some(size);
|
||||||
db::update_item(&conn, item.clone())?;
|
db::update_item(conn, item.clone())?;
|
||||||
} else {
|
} else {
|
||||||
debug!(
|
debug!(
|
||||||
"MAIN: Unable to update size of item due to missing file {:?}",
|
"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");
|
debug!("MAIN: Updating item meta");
|
||||||
for kv in args.item.meta.iter() {
|
for kv in args.item.meta.iter() {
|
||||||
let meta = db::Meta {
|
let meta = db::Meta {
|
||||||
|
|||||||
Reference in New Issue
Block a user