choose what to arrange: -kinds, -exclude, am survey
-kinds picks any of image, raw, video (default all). -exclude skips files and whole directories by name glob, and can be repeated. am survey stats media per directory (counts by kind, videos over 1G, sizes) so things like ripped DVDs stand out before arranging. It never opens files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,49 @@ func TestSourceSkips(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceFiltered(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
for _, p := range []string{
|
||||
"pics/a.jpg",
|
||||
"pics/b.NEF",
|
||||
"pics/clip.mov",
|
||||
"rips/Movie/VIDEO_TS/VTS_01_1.mp4",
|
||||
"rips/film.mkv",
|
||||
"rips/cover.jpg",
|
||||
} {
|
||||
full := filepath.Join(root, p)
|
||||
if err := os.MkdirAll(filepath.Dir(full), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(full, nil, 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
f Filter
|
||||
want string
|
||||
}{
|
||||
{"everything", Filter{}, "pics/a.jpg pics/b.NEF pics/clip.mov rips/Movie/VIDEO_TS/VTS_01_1.mp4 rips/cover.jpg rips/film.mkv"},
|
||||
{"images", Filter{Classes: map[Class]bool{Image: true}}, "pics/a.jpg rips/cover.jpg"},
|
||||
{"no video", Filter{Classes: map[Class]bool{Image: true, Raw: true}}, "pics/a.jpg pics/b.NEF rips/cover.jpg"},
|
||||
{"exclude dir", Filter{Exclude: []string{"VIDEO_TS"}}, "pics/a.jpg pics/b.NEF pics/clip.mov rips/cover.jpg rips/film.mkv"},
|
||||
{"exclude glob", Filter{Exclude: []string{"*.mkv", "rip*"}}, "pics/a.jpg pics/b.NEF pics/clip.mov"},
|
||||
{"root not excluded", Filter{Exclude: []string{filepath.Base(root)}}, "pics/a.jpg pics/b.NEF pics/clip.mov rips/Movie/VIDEO_TS/VTS_01_1.mp4 rips/cover.jpg rips/film.mkv"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
var got []string
|
||||
for p := range SourceFiltered(root, test.f) {
|
||||
rel, _ := filepath.Rel(root, p)
|
||||
got = append(got, rel)
|
||||
}
|
||||
if g := strings.Join(got, " "); g != test.want {
|
||||
t.Errorf("%s:\n got %s\nwant %s", test.name, g, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// arranged returns a store with one file arranged into it, and that Media.
|
||||
func arranged(t *testing.T) (string, Media) {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user