next9: + filter_phsr 끝 (d7da812: P keep/*** 가 받는 쪽에만 있는 안쪽 폴더도 지킴) - 시험판 982

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
review_d2dc267 v2026.10.18_982
RyuJongJin 2026-10-20 14:18:37 +09:00
commit f5a01a1ecd
2 changed files with 11 additions and 2 deletions

View File

@ -203,7 +203,9 @@ class RsyncFilterRule {
} }
final anchored = p.startsWith('/'); final anchored = p.startsWith('/');
if (anchored) p = p.substring(1); if (anchored) p = p.substring(1);
final whole = anchored || p.contains('/') || p.contains('**'); // "이름/***" 은 원래 패턴에 / 가 있으므로 경로로 맞춘다 (28 확인 10/20: 이름으로만 맞추면 받는 쪽에만 있는 keep/sub 같은
// 안쪽 폴더를 "P keep/***" 가 지키지 못해 미리 보기가 더 지운다고 보였다 - 거른 폴더 안으로 내려가지 않는 보내는 쪽에서는 드러나지 않음)
final whole = anchored || all || p.contains('/') || p.contains('**');
// rsync 의 wildmatch 는 바이트로 맞춘다 - 패턴 · 이름을 UTF-8 바이트 (한 글자 = 한 바이트) 로 바꿔 맞춘다 // rsync 의 wildmatch 는 바이트로 맞춘다 - 패턴 · 이름을 UTF-8 바이트 (한 글자 = 한 바이트) 로 바꿔 맞춘다
final body = _glob(_bytes(p)) + (all ? '(?:/.*)?' : ''); final body = _glob(_bytes(p)) + (all ? '(?:/.*)?' : '');
_re = RegExp(anchored ? '^$body\$' : whole ? '^(?:.*/)?$body\$' : '^$body\$'); _re = RegExp(anchored ? '^$body\$' : whole ? '^(?:.*/)?$body\$' : '^$body\$');

View File

@ -24,7 +24,7 @@ import 'support/rsync_scenes.dart';
/// 보내는 쪽 (양쪽에 같은 이름이 많게 - H · S 는 보내기, P · R 은 지우기에 걸리게) /// 보내는 쪽 (양쪽에 같은 이름이 많게 - H · S 는 보내기, P · R 은 지우기에 걸리게)
const _src = [ const _src = [
'a.txt', 'b.log', 'keep.log', 'both.txt', 'both.log', 'shared/x.txt', 'shared/y.log', 'build/x.o', 'build/sub/y.o', 'a.txt', 'b.log', 'keep.log', 'both.txt', 'both.log', 'shared/x.txt', 'shared/y.log', 'build/x.o', 'build/sub/y.o',
'sub/c.txt', 'sub/deep/d.txt', 'sub/deep/e.log', 'tmp/t.txt', '한글 폴더/가.txt', 'docs/r.md', 'z.txt', 'sub/c.txt', 'sub/deep/d.txt', 'sub/deep/e.log', 'tmp/t.txt', '한글 폴더/가.txt', 'docs/r.md', 'z.txt', 'keep/k.txt',
]; ];
/// 받는 쪽 (같은 이름은 크기가 달라 늘 바뀜 · 받는 쪽에만 있는 것은 지우기 대상) /// 받는 쪽 (같은 이름은 크기가 달라 늘 바뀜 · 받는 쪽에만 있는 것은 지우기 대상)
@ -32,6 +32,8 @@ const _dst = [
'a.txt', 'keep.log', 'both.txt', 'both.log', 'shared/x.txt', 'shared/onlyd.log', 'shared/onlyd.txt', 'build/old.o', 'a.txt', 'keep.log', 'both.txt', 'both.log', 'shared/x.txt', 'shared/onlyd.log', 'shared/onlyd.txt', 'build/old.o',
'old/keep.log', 'old/gone.txt', 'old2/deep/x/keep.log', 'old2/deep/x/g.txt', 'old2/e.txt', 'tmp/old.txt', 'extra.txt', 'old/keep.log', 'old/gone.txt', 'old2/deep/x/keep.log', 'old2/deep/x/g.txt', 'old2/e.txt', 'tmp/old.txt', 'extra.txt',
'extra.log', 'sub/deep/z.txt', '한글 폴더/나.txt', 'onlydst/a.bak', 'extra.log', 'sub/deep/z.txt', '한글 폴더/나.txt', 'onlydst/a.bak',
// 28 확인 (10/20): 원본에도 있는 폴더 안의, 받는 쪽에만 있는 파일 · 하위 폴더 ("P keep/***" 가 안쪽까지 지키는지)
'keep/extra.txt', 'keep/sub/deep.txt',
]; ];
/// 규칙 장면 (지우기 포함이 많게 - 지우기가 데이터 쪽 위험) /// 규칙 장면 (지우기 포함이 많게 - 지우기가 데이터 쪽 위험)
@ -67,6 +69,11 @@ const phsrOptions = [
'-a --delete --filter="P shared/onlyd.*" --filter="H shared/"', '-a --delete --filter="P shared/onlyd.*" --filter="H shared/"',
'-a --filter="H *.log"', '-a --filter="H *.log"',
'-a --filter="P *.log" --exclude=*.txt', '-a --filter="P *.log" --exclude=*.txt',
// 28 확인 (10/20): "이름/***" 이 안쪽 (받는 쪽에만 있는 하위 폴더) 까지
'-a --delete --filter="R keep/extra.txt" --filter="P keep/***"',
'-a --delete --filter="P keep/***"',
'-a --delete --exclude=keep/***',
'-a --delete --filter="H keep/***"',
]; ];
void main() { void main() {