feat: make digest_value optional and add digest display
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
1d9ca1b9dd
commit
1aaf1e6221
@@ -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(
|
||||
@@ -152,8 +163,8 @@ pub fn mode_list(
|
||||
Alignment::RIGHT,
|
||||
),
|
||||
Err(_) => Cell::new_align("Missing", Alignment::RIGHT)
|
||||
.with_style(Attr::ForegroundColor(color::RED))
|
||||
.with_style(Attr::Bold),
|
||||
.with_style(Attr::ForegroundColor(color::RED))
|
||||
.with_style(Attr::Bold),
|
||||
},
|
||||
ColumnType::FilePath => Cell::new(&string_column(
|
||||
item_path.clone().into_os_string().into_string().unwrap(),
|
||||
|
||||
@@ -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