feat: make digest_value optional and add digest display
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
1d9ca1b9dd
commit
1aaf1e6221
@@ -32,9 +32,6 @@ lazy_static! {
|
||||
FOREIGN KEY(id) REFERENCES items(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY(id, name));"
|
||||
),
|
||||
M::up(
|
||||
"ALTER TABLE items ALTER COLUMN compression SET DEFAULT 'none';"
|
||||
),
|
||||
M::up(
|
||||
"ALTER TABLE items ADD COLUMN digest_type TEXT NOT NULL DEFAULT 'none';"
|
||||
),
|
||||
@@ -51,7 +48,7 @@ pub struct Item {
|
||||
pub size: Option<i64>,
|
||||
pub compression: String,
|
||||
pub digest_type: String,
|
||||
pub digest_value: String,
|
||||
pub digest_value: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -53,6 +53,8 @@ pub enum ColumnType {
|
||||
Time,
|
||||
Size,
|
||||
Compression,
|
||||
DigestType,
|
||||
DigestValue,
|
||||
FileSize,
|
||||
FilePath,
|
||||
Tags,
|
||||
|
||||
@@ -142,6 +142,17 @@ pub fn mode_list(
|
||||
ColumnType::Compression => {
|
||||
Cell::new(&string_column(item.compression.to_string(), column_width))
|
||||
}
|
||||
ColumnType::DigestType => {
|
||||
Cell::new(&string_column(item.digest_type.to_string(), column_width))
|
||||
}
|
||||
ColumnType::DigestValue => {
|
||||
match item.digest_value {
|
||||
Some(ref value) => Cell::new(&string_column(value.to_string(), column_width)),
|
||||
None => Cell::new("Missing")
|
||||
.with_style(Attr::ForegroundColor(color::RED))
|
||||
.with_style(Attr::Bold),
|
||||
}
|
||||
}
|
||||
ColumnType::FileSize => match item_path.metadata() {
|
||||
Ok(metadata) => Cell::new_align(
|
||||
&size_column(
|
||||
|
||||
@@ -72,7 +72,7 @@ pub fn mode_save(
|
||||
size: None,
|
||||
compression: compression_type.to_string(),
|
||||
digest_type: digest_type.to_string(),
|
||||
digest_value: String::new(),
|
||||
digest_value: Some(String::new()),
|
||||
};
|
||||
|
||||
let id = db::insert_item(conn, item.clone())?;
|
||||
@@ -169,7 +169,7 @@ pub fn mode_save(
|
||||
// Finalize the digest and log the result
|
||||
let digest = digest_engine.finalize()?;
|
||||
debug!("DIGEST: {}", digest);
|
||||
item.digest_value = digest;
|
||||
item.digest_value = Some(digest);
|
||||
|
||||
db::update_item(conn, item.clone())?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user