feat: add compression and digest support with database schema updates
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
9b61a37036
commit
bbdfe19836
@@ -1,6 +1,6 @@
|
||||
use crate::digest_engine::DigestEngine;
|
||||
use anyhow::Result;
|
||||
use std::io::{self, Write};
|
||||
use crate::digest_engine::DigestEngine;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Default)]
|
||||
pub struct DigestEngineNone {}
|
||||
@@ -15,11 +15,11 @@ impl DigestEngine for DigestEngineNone {
|
||||
fn create(&self) -> Result<Box<dyn Write>> {
|
||||
Ok(Box::new(DummyWriter::new()))
|
||||
}
|
||||
|
||||
|
||||
fn finalize(&mut self) -> io::Result<String> {
|
||||
Ok("none".to_string())
|
||||
}
|
||||
|
||||
|
||||
fn update(&mut self, _data: &[u8]) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use anyhow::{anyhow, Result, Context};
|
||||
use crate::digest_engine::ProgramWriter;
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use log::*;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use crate::digest_engine::ProgramWriter;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
@@ -34,17 +34,14 @@ impl DigestEngine for DigestEngineProgram {
|
||||
fn is_supported(&self) -> bool {
|
||||
self.supported
|
||||
}
|
||||
|
||||
|
||||
fn create(&self) -> Result<Box<dyn Write>> {
|
||||
debug!("DIGEST: Writting using {:?}", *self);
|
||||
|
||||
let program = self.program.clone();
|
||||
let args = self.args.clone();
|
||||
|
||||
debug!(
|
||||
"DIGEST: Executing command: {:?} {:?}",
|
||||
program, args
|
||||
);
|
||||
debug!("DIGEST: Executing command: {:?} {:?}", program, args);
|
||||
|
||||
let mut process = Command::new(program.clone())
|
||||
.args(args.clone())
|
||||
@@ -65,7 +62,7 @@ impl DigestEngine for DigestEngineProgram {
|
||||
fn finalize(&mut self) -> io::Result<String> {
|
||||
Ok("program".to_string())
|
||||
}
|
||||
|
||||
|
||||
fn update(&mut self, _data: &[u8]) {
|
||||
// This is handled by the ProgramWriter implementation
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use std::io::Write;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
|
||||
use crate::digest_engine::DigestEngine;
|
||||
|
||||
@@ -54,7 +54,7 @@ impl DigestEngine for DigestEngineSha256 {
|
||||
let result = self.hasher.clone().finalize();
|
||||
Ok(format!("{:x}", result))
|
||||
}
|
||||
|
||||
|
||||
fn update(&mut self, data: &[u8]) {
|
||||
self.hasher.update(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user