重复文件扫描跳过 .workbuddy\workspace\sessions 子树

智能体会话快照整棵目录不参与查重,任意盘符、忽略大小写,按连续路径
段匹配;新测试覆盖命中与不误伤两种形状。0.1.13 重新打包同步哈希。
dev
lijunjie 2026-11-25 14:24:35 +08:00
parent 450086e835
commit 56ee563dee
6 changed files with 51 additions and 7 deletions

View File

@ -29,7 +29,7 @@ use squid_core::{Bytes, Category, CleanupItem, ItemKind};
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicU64, Ordering};
/// Files below this size are never offered: deduplicating a 4 KiB config is
@ -235,6 +235,31 @@ fn skip_dir(name: &str) -> bool {
SKIP.iter().any(|wanted| lower == *wanted)
}
/// Path-subtree exclusions that only matter as a *sequence*: WorkBuddy's
/// `\.workbuddy\workspace\sessions` folders snapshot copies of files the
/// agent was created from, so deduping them would re-offer churn the tool
/// regenerates itself — on whichever volume it happens to live. Matched as
/// consecutive normal path components, case- and drive-independent.
fn excluded_subtree(dir: &Path) -> bool {
const SEGMENTS: [&str; 3] = [".workbuddy", "workspace", "sessions"];
// Cheap guard: the walk prunes at the `sessions` door, so anything else
// can never match while descending.
if !dir
.file_name()
.is_some_and(|name| name.to_string_lossy().eq_ignore_ascii_case("sessions"))
{
return false;
}
let names: Vec<String> = dir
.components()
.filter_map(|part| match part {
std::path::Component::Normal(name) => Some(name.to_string_lossy().to_lowercase()),
_ => None,
})
.collect();
names.len() >= SEGMENTS.len() && names.windows(SEGMENTS.len()).any(|w| w == SEGMENTS)
}
/// Run the funnel. Groups stream out as `Event::Group { kind: "dup", … }`;
/// the return value is the same data collected, with per-copy locks
/// resolved, so the command layer can hand the frontend a finished list too.
@ -271,7 +296,7 @@ pub fn scan(
continue;
};
if file_type.is_dir() {
if skip_dir(&entry.file_name().to_string_lossy()) {
if skip_dir(&entry.file_name().to_string_lossy()) || excluded_subtree(&path) {
continue;
}
stack.push((path, depth + 1));
@ -570,6 +595,22 @@ mod tests {
}
}
#[test]
fn workbuddy_session_snapshots_are_never_walked() {
assert!(excluded_subtree(Path::new(
r"C:\.workbuddy\workspace\sessions"
)));
assert!(excluded_subtree(Path::new(
r"D:\Work\.WorkBuddy\Workspace\Sessions"
)));
assert!(!excluded_subtree(Path::new(
r"C:\Users\dev\workspace\sessions"
)));
assert!(!excluded_subtree(Path::new(
r"C:\.workbuddy\workspace\sessions-notes"
)));
}
#[test]
fn identical_files_land_in_one_group_with_the_neat_copy_kept() {
let Some(root) = scratch("same") else { return };

View File

@ -18,6 +18,9 @@ Squid 0.1.13 更新说明
同一套样式;认不出归属的落入「其他软件」。菜单位置类别与计数不变。
调整
- 重复文件扫描不再进入 WorkBuddy 的会话快照目录:任何盘符上的
`.workbuddy\workspace\sessions\…` 整棵子树直接跳过——那是智能体自己
生成的文件副本,列出来只会重复劳动。
- 电脑概览页排版改版:处理器与内存合并为一张卡(上下分布),存储空间卡
加宽、每个盘符收成一行的表格感排版(盘符|进度条|用量与容量),日常
维护三个入口竖排进右列——指标行按 30% / 42% / 28% 三列分布,区块间距

View File

@ -1,2 +1,2 @@
5ed5247bc85e8b5157b2d1ed797a586c4bd8cecaa848ee628ca5b406978249d8 Squid-Setup-0.1.13-win-x64.exe
3ef89d39e19d9a1b4eb625168827a7d968f77bd9cf449832db615b61ec5ccda9 Squid-0.1.13-portable-win-x64.zip
24256da12d3d3de03777e5b916c7aaef14f9ec512befe044df43572e1ea56c67 Squid-Setup-0.1.13-win-x64.exe
7a4e50877b72c6340ad09bfab710a3892a3d6a3511a4d2c612908a121d776431 Squid-0.1.13-portable-win-x64.zip

File diff suppressed because one or more lines are too long