fix: remove duplicate digest argument and adjust imports
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
4c2df3d743
commit
9ba3a31e95
@@ -5,8 +5,8 @@ use std::fs;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::process::{Command, Stdio};
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
use crate::compression_engine::CompressionEngine;
|
use crate::compression_engine::CompressionEngine;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result, Context};
|
||||||
use log::*;
|
use log::*;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@@ -51,7 +51,7 @@ impl DigestEngine for DigestEngineProgram {
|
|||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.with_context(|| anyhow!(
|
.context(anyhow!(
|
||||||
"Problem spawning child process: {:?} {:?}",
|
"Problem spawning child process: {:?} {:?}",
|
||||||
program,
|
program,
|
||||||
args
|
args
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ extern crate lazy_static;
|
|||||||
|
|
||||||
pub mod compression_engine;
|
pub mod compression_engine;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
|
pub mod digest_engine;
|
||||||
//pub mod item;
|
//pub mod item;
|
||||||
|
|
||||||
|
|
||||||
extern crate term;
|
extern crate term;
|
||||||
|
|
||||||
lazy_static! {
|
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"))]
|
#[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>,
|
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"))]
|
#[arg(help("Digest algorithm to use when saving items"))]
|
||||||
digest: Option<String>,
|
digest: Option<String>,
|
||||||
|
|
||||||
#[arg(help_heading("Item Options"), short, long, env("KEEP_COMPRESSION"))]
|
#[arg(help_heading("Item Options"), short, long, env("KEEP_COMPRESSION"))]
|
||||||
#[arg(help("Compression algorithm to use when saving items"))]
|
#[arg(help("Compression algorithm to use when saving items"))]
|
||||||
compression: Option<String>,
|
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)]
|
#[derive(Parser, Debug)]
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use anyhow::Result;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::db;
|
|
||||||
use crate::compression_engine::CompressionType;
|
use crate::compression_engine::CompressionType;
|
||||||
|
use crate::db;
|
||||||
use clap::error::ErrorKind;
|
use clap::error::ErrorKind;
|
||||||
use clap::Command;
|
use clap::Command;
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
|
|||||||
31
src/tests.rs
31
src/tests.rs
@@ -57,37 +57,6 @@ mod tests {
|
|||||||
cmd,
|
cmd,
|
||||||
output.status
|
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
|
// Helper function to check if a file exists in the data directory
|
||||||
|
|||||||
Reference in New Issue
Block a user