fix: remove duplicate digest argument and adjust imports

This commit is contained in:
Andrew Phillips
2025-05-12 22:11:56 -03:00
committed by Andrew Phillips (aider)
parent 4c2df3d743
commit 9ba3a31e95
5 changed files with 6 additions and 41 deletions

View File

@@ -5,8 +5,8 @@ use std::fs;
use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::fs::PermissionsExt;
use std::process::{Command, Stdio};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use crate::compression_engine::CompressionEngine;

View File

@@ -1,4 +1,4 @@
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Result, Context};
use log::*;
use std::env;
use std::fs;
@@ -51,7 +51,7 @@ impl DigestEngine for DigestEngineProgram {
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.with_context(|| anyhow!(
.context(anyhow!(
"Problem spawning child process: {:?} {:?}",
program,
args

View File

@@ -20,9 +20,9 @@ extern crate lazy_static;
pub mod compression_engine;
pub mod db;
pub mod digest_engine;
//pub mod item;
extern crate term;
lazy_static! {
@@ -105,17 +105,13 @@ struct ItemArgs {
#[arg(help("Set metadata for the item using the format KEY=[VALUE], the metadata will be removed if VALUE is not provided"))]
meta: Vec<KeyValue>,
#[arg(help_heading("Item Options"), short, long, env("KEEP_DIGEST"))]
#[arg(help_heading("Item Options"), long, env("KEEP_DIGEST"))]
#[arg(help("Digest algorithm to use when saving items"))]
digest: Option<String>,
#[arg(help_heading("Item Options"), short, long, env("KEEP_COMPRESSION"))]
#[arg(help("Compression algorithm to use when saving items"))]
compression: Option<String>,
#[arg(help_heading("Item Options"), short, long, env("KEEP_DIGEST"))]
#[arg(help("Digest algorithm to use when saving items"))]
digest: Option<String>,
}
#[derive(Parser, Debug)]

View File

@@ -2,8 +2,8 @@ use anyhow::Result;
use std::path::PathBuf;
use std::str::FromStr;
use crate::db;
use crate::compression_engine::CompressionType;
use crate::db;
use clap::error::ErrorKind;
use clap::Command;
use log::{debug, info};

View File

@@ -57,37 +57,6 @@ mod tests {
cmd,
output.status
);
// Test with digest option
let cmd = format!("echo {} | {} --digest sha256 -c none none", INPUT_A, env);
println!("RUNNING: {}", cmd);
let output = run_sh(cmd.as_str());
assert!(
output.status.success(),
"Command failed: {} {}",
cmd,
output.status
);
let cmd = format!("echo {} | {} --digest md5 -c none none", INPUT_A, env);
println!("RUNNING: {}", cmd);
let output = run_sh(cmd.as_str());
assert!(
output.status.success(),
"Command failed: {} {}",
cmd,
output.status
);
let cmd = format!("echo {} | {} --digest program -p md5sum -c none none", INPUT_A, env);
println!("RUNNING: {}", cmd);
let output = run_sh(cmd.as_str());
assert!(
output.status.success(),
"Command failed: {} {}",
cmd,
output.status
);
}
// Helper function to check if a file exists in the data directory