fix: correct critical bugs and improve pipe streaming performance

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
This commit is contained in:
2026-03-11 20:45:05 -03:00
parent e8ea42506e
commit 8a8a6e1c4b
53 changed files with 813 additions and 640 deletions

View File

@@ -189,10 +189,7 @@ pub struct Settings {
impl Settings {
/// Create unified settings from config and args with proper priority
pub fn new(args: &Args, default_dir: PathBuf) -> Result<Self> {
debug!(
"CONFIG: Creating settings with default dir: {:?}",
default_dir
);
debug!("CONFIG: Creating settings with default dir: {default_dir:?}");
let config_path = if let Some(config_path) = &args.options.config {
config_path.clone()
@@ -208,21 +205,21 @@ impl Settings {
} else {
PathBuf::from("~/.config/keep/config.yml")
};
debug!("CONFIG: Using default config path: {:?}", default_path);
debug!("CONFIG: Using default config path: {default_path:?}");
default_path
};
debug!("CONFIG: Using config path: {:?}", config_path);
debug!("CONFIG: Using config path: {config_path:?}");
let mut config_builder = config::Config::builder();
// Load config file if it exists
if config_path.exists() {
debug!("CONFIG: Loading config file: {:?}", config_path);
debug!("CONFIG: Loading config file: {config_path:?}");
config_builder =
config_builder.add_source(config::File::from(config_path.clone()).required(false));
} else {
debug!("CONFIG: Config file does not exist: {:?}", config_path);
debug!("CONFIG: Config file does not exist: {config_path:?}");
}
// Add environment variables
@@ -234,7 +231,7 @@ impl Settings {
// Override with CLI args
if let Some(dir) = &args.options.dir {
debug!("CONFIG: Overriding dir with CLI arg: {:?}", dir);
debug!("CONFIG: Overriding dir with CLI arg: {dir:?}");
config_builder = config_builder.set_override("dir", dir.to_str().unwrap())?;
}
@@ -302,7 +299,7 @@ impl Settings {
match config.try_deserialize::<Settings>() {
Ok(mut settings) => {
debug!("CONFIG: Successfully deserialized settings: {:?}", settings);
debug!("CONFIG: Successfully deserialized settings: {settings:?}");
// Set defaults for list_format if not provided
if settings.list_format.is_empty() {
@@ -393,15 +390,15 @@ impl Settings {
// Set dir to default if not provided or is empty
if settings.dir == PathBuf::new() {
debug!("CONFIG: Setting default dir: {:?}", default_dir);
debug!("CONFIG: Setting default dir: {default_dir:?}");
settings.dir = default_dir;
}
debug!("CONFIG: Final settings: {:?}", settings);
debug!("CONFIG: Final settings: {settings:?}");
Ok(settings)
}
Err(e) => {
error!("CONFIG: Failed to deserialize settings: {}", e);
error!("CONFIG: Failed to deserialize settings: {e}");
Err(e.into())
}
}
@@ -422,9 +419,9 @@ impl Settings {
if let Some(server) = &self.server {
// First check for password_file
if let Some(password_file) = &server.password_file {
debug!("CONFIG: Reading password from file: {:?}", password_file);
debug!("CONFIG: Reading password from file: {password_file:?}");
let password = fs::read_to_string(password_file)
.with_context(|| format!("Failed to read password file: {:?}", password_file))?
.with_context(|| format!("Failed to read password file: {password_file:?}"))?
.trim()
.to_string();
return Ok(Some(password));