fix: resolve compilation errors and warnings in keep crate

Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-07-29 15:37:43 -03:00
parent 8814d02264
commit 3008f3fec0
4 changed files with 25 additions and 9 deletions

View File

@@ -36,6 +36,24 @@ impl CompressionEngineProgram {
} }
} }
fn get_program_path(program: &str) -> Result<String> {
debug!("COMPRESSION: Looking for executable: {}", program);
if let Ok(path) = env::var("PATH") {
for p in path.split(':') {
let p_str = format!("{}/{}", p, program);
let stat = fs::metadata(p_str.clone());
if let Ok(stat) = stat {
let md = stat;
let permissions = md.permissions();
if md.is_file() && permissions.mode() & 0o111 != 0 {
return Ok(p_str);
}
}
}
}
Err(anyhow!("Unable to find binary {} in PATH", program))
}
impl CompressionEngine for CompressionEngineProgram { impl CompressionEngine for CompressionEngineProgram {
fn is_supported(&self) -> bool { fn is_supported(&self) -> bool {
self.supported self.supported

View File

@@ -9,13 +9,10 @@ extern crate directories;
use directories::ProjectDirs; use directories::ProjectDirs;
extern crate prettytable; extern crate prettytable;
use prettytable::format;
use prettytable::format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR; use prettytable::format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR;
use prettytable::format::{Alignment, TableFormat};
use std::str::FromStr; use std::str::FromStr;
#[macro_use]
extern crate lazy_static; extern crate lazy_static;
pub mod compression_engine; pub mod compression_engine;

View File

@@ -8,8 +8,9 @@ use crate::compression_engine::COMPRESSION_PROGRAMS;
use crate::compression_engine::CompressionType; use crate::compression_engine::CompressionType;
use crate::compression_engine::program::CompressionEngineProgram; use crate::compression_engine::program::CompressionEngineProgram;
use crate::FORMAT_BOX_CHARS_NO_BORDER_LINE_SEPARATOR; use prettytable::format::TableFormat;
use crate::FORMAT_NO_BORDER_LINE_SEPARATOR; use crate::modes::common::get_format_box_chars_no_border_line_separator;
use prettytable::format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR;
use prettytable::color; use prettytable::color;
use prettytable::row; use prettytable::row;
use prettytable::{Attr, Cell, Row, Table}; use prettytable::{Attr, Cell, Row, Table};
@@ -21,7 +22,7 @@ fn build_path_table(data_path: PathBuf, db_path: PathBuf) -> Table {
let mut path_table = Table::new(); let mut path_table = Table::new();
if std::io::stdout().is_terminal() { if std::io::stdout().is_terminal() {
path_table.set_format(*FORMAT_BOX_CHARS_NO_BORDER_LINE_SEPARATOR); path_table.set_format(get_format_box_chars_no_border_line_separator());
} else { } else {
path_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR); path_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR);
} }
@@ -57,7 +58,7 @@ fn build_path_table(data_path: PathBuf, db_path: PathBuf) -> Table {
fn build_compression_table() -> Table { fn build_compression_table() -> Table {
let mut compression_table = Table::new(); let mut compression_table = Table::new();
if std::io::stdout().is_terminal() { if std::io::stdout().is_terminal() {
compression_table.set_format(*FORMAT_BOX_CHARS_NO_BORDER_LINE_SEPARATOR); compression_table.set_format(get_format_box_chars_no_border_line_separator());
} else { } else {
compression_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR); compression_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR);
} }
@@ -114,7 +115,7 @@ fn build_compression_table() -> Table {
fn build_meta_plugin_table(enabled_meta_plugins: &Vec<MetaPluginType>) -> Table { fn build_meta_plugin_table(enabled_meta_plugins: &Vec<MetaPluginType>) -> Table {
let mut meta_plugin_table = Table::new(); let mut meta_plugin_table = Table::new();
if std::io::stdout().is_terminal() { if std::io::stdout().is_terminal() {
meta_plugin_table.set_format(*FORMAT_BOX_CHARS_NO_BORDER_LINE_SEPARATOR); meta_plugin_table.set_format(get_format_box_chars_no_border_line_separator());
} else { } else {
meta_plugin_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR); meta_plugin_table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR);
} }

View File

@@ -17,7 +17,7 @@ mod tests {
cmd.args(args) cmd.args(args)
.env("KEEP_DIR", keep_dir); .env("KEEP_DIR", keep_dir);
if let Some(data) = stdin_data { if let Some(_data) = stdin_data {
cmd.stdin(std::process::Stdio::piped()); cmd.stdin(std::process::Stdio::piped());
} }