Release 0.1.1 #3
@@ -102,7 +102,8 @@ pub async fn list_with_metadata(pool: &SqlitePool, prefix: &str) -> Result<Vec<M
|
|||||||
let rows = sqlx::query_as::<_, MemoryEntryMeta>(
|
let rows = sqlx::query_as::<_, MemoryEntryMeta>(
|
||||||
"SELECT path,
|
"SELECT path,
|
||||||
CASE WHEN content = '' THEN 0
|
CASE WHEN content = '' THEN 0
|
||||||
ELSE LENGTH(content) - LENGTH(REPLACE(content, char(10), '')) + 1
|
ELSE LENGTH(content) - LENGTH(REPLACE(content, char(10), ''))
|
||||||
|
+ CASE WHEN substr(content, -1, 1) = char(10) THEN 0 ELSE 1 END
|
||||||
END AS line_count,
|
END AS line_count,
|
||||||
LENGTH(CAST(content AS BLOB)) AS byte_len
|
LENGTH(CAST(content AS BLOB)) AS byte_len
|
||||||
FROM memory_docs
|
FROM memory_docs
|
||||||
|
|||||||
@@ -229,43 +229,3 @@ fn walk(root: &Path, dir: &Path, depth: usize, max_depth: usize, dirs_only: bool
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod meta_smoke {
|
|
||||||
use super::*;
|
|
||||||
const SP: &str = "/private/tmp/claude-501/-Users-dguiducci-projects-skald-circle/1cb4c456-6a62-4c67-abf8-bb93ef73e30c/scratchpad/lf";
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn human_size_fmt() {
|
|
||||||
assert_eq!(human_size(0), "0 B");
|
|
||||||
assert_eq!(human_size(512), "512 B");
|
|
||||||
assert_eq!(human_size(18 * 1024), "18 KB");
|
|
||||||
assert_eq!(human_size(1024 * 1024 + 400 * 1024), "1.4 MB");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn line_counts() {
|
|
||||||
assert_eq!(count_lines(b""), 0);
|
|
||||||
assert_eq!(count_lines(b"a\nb\nc\n"), 3);
|
|
||||||
assert_eq!(count_lines(b"no newline"), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn entries() {
|
|
||||||
let t = std::path::Path::new(SP).join("three.txt");
|
|
||||||
let e = file_entry(&t, "three.txt".into());
|
|
||||||
println!("three.txt -> {}", serde_json::to_string(&e).unwrap());
|
|
||||||
assert_eq!(e.line_count, Some(3));
|
|
||||||
|
|
||||||
let o = std::path::Path::new(SP).join("one.txt");
|
|
||||||
let e = file_entry(&o, "one.txt".into());
|
|
||||||
println!("one.txt -> {}", serde_json::to_string(&e).unwrap());
|
|
||||||
assert_eq!(e.line_count, Some(1));
|
|
||||||
|
|
||||||
let b = std::path::Path::new(SP).join("blob.bin");
|
|
||||||
let e = file_entry(&b, "blob.bin".into());
|
|
||||||
println!("blob.bin -> {}", serde_json::to_string(&e).unwrap());
|
|
||||||
assert_eq!(e.line_count, None); // binary: size only
|
|
||||||
assert!(e.size.is_some());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user