Critical bug fixes:
- save_item now returns real Item from database, not a hardcoded fake
- AsyncDataService::save() reuses self.sync_service instead of creating redundant instance
- GenerateStatus trait signature mismatch fixed (CLI/API decoupling)
Performance improvements (pipe path untouched):
- CompressionEngine::open() returns Box<dyn Read + Send> enabling true streaming
- mode_get eliminates triple full-file read (was sampling then re-reading entire file)
- FilteringReader adds fast-path bypass when no filters, pre-allocates temp buffer
- text.rs meta plugin processes &[u8] slice directly, eliminates data.to_vec() clone
API correctness:
- Tag parse errors now return 400 instead of being silently discarded
- compute_diff uses similar crate (LCS-based) instead of naive positional comparison
Cleanup:
- Modernize string formatting (format!({x})) across codebase
- Remove redundant DB query in get mode
- Derive Debug/ToSchema on public types
- Delete placeholder test files with no real assertions
- Extract parse_comma_tags utility function
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
use anyhow::Result;
|
|
use log::*;
|
|
use std::io::Write;
|
|
|
|
use lz4_flex::frame::{FrameDecoder, FrameEncoder};
|
|
use std::fs::File;
|
|
use std::io::Read;
|
|
use std::path::PathBuf;
|
|
|
|
use crate::compression_engine::CompressionEngine;
|
|
|
|
#[derive(Debug, Eq, PartialEq, Clone, Default)]
|
|
pub struct CompressionEngineLZ4 {}
|
|
|
|
impl CompressionEngineLZ4 {
|
|
pub fn new() -> CompressionEngineLZ4 {
|
|
CompressionEngineLZ4 {}
|
|
}
|
|
}
|
|
|
|
impl CompressionEngine for CompressionEngineLZ4 {
|
|
fn open(&self, file_path: PathBuf) -> Result<Box<dyn Read + Send>> {
|
|
debug!("COMPRESSION: Opening {:?} using {:?}", file_path, *self);
|
|
|
|
let file = File::open(file_path)?;
|
|
Ok(Box::new(FrameDecoder::new(file)))
|
|
}
|
|
|
|
fn create(&self, file_path: PathBuf) -> Result<Box<dyn Write>> {
|
|
debug!("COMPRESSION: Writing to {:?} using {:?}", file_path, *self);
|
|
|
|
let file = File::create(file_path)?;
|
|
let lz4_write = FrameEncoder::new(file).auto_finish();
|
|
|
|
Ok(Box::new(lz4_write))
|
|
}
|
|
|
|
fn clone_box(&self) -> Box<dyn CompressionEngine> {
|
|
Box::new(self.clone())
|
|
}
|
|
}
|