Add finding and removing folders without music

The new Cleanup tab lists the top-most folders in either library that
contain no music file (per the pair's extensions). Removing them needs
confirmation, plus an explicit acknowledgement when they still hold
files; each folder is re-checked for music and moved into the
quarantine (undoable from History, purged after the retention period).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cdnutterandClaude Opus 5.5 committed 2026-09-30 12:24:47 -07:00
1 parent e0617047f7
commit 30fab3a208
11 files changed
+760 -8

No files matched your search

+46
View File
@@ -101,6 +101,9 @@ func (s *Server) Handler() http.Handler {
r.Post("/renames", s.handleRenames)
r.Post("/link-identical", s.handleLinkIdentical)
r.Get("/tree", s.handleTree)
r.Get("/empty-folders", s.handleEmptyFolders)
r.Post("/empty-folders/scan", s.handleEmptyFolderScan)
r.Post("/empty-folders/remove", s.handleRemoveEmptyFolders)
r.Post("/build", s.handleBuild)
r.Post("/remove", s.handleRemove)
})
@@ -740,3 +743,46 @@ func (s *Server) preAction(w http.ResponseWriter, r *http.Request, pairID int64,
}
return true
}
// ---- folders without music ----
func (s *Server) handleEmptyFolders(w http.ResponseWriter, r *http.Request) {
id, _ := idParam(r)
writeJSON(w, 200, map[string]any{"scan": s.eng.NoMusicResult(id), "dry_run": s.st.DryRun(r.Context())})
}
func (s *Server) handleEmptyFolderScan(w http.ResponseWriter, r *http.Request) {
id, _ := idParam(r)
var body struct {
Side string `json:"side"`
}
if !readJSON(w, r, &body) {
return
}
j, err := s.eng.StartNoMusicScan(id, body.Side)
if err != nil {
opErr(w, err)
return
}
writeJSON(w, 202, j)
}
func (s *Server) handleRemoveEmptyFolders(w http.ResponseWriter, r *http.Request) {
id, _ := idParam(r)
var body struct {
Folders []string `json:"folders"` // must come from the latest scan
}
if !readJSON(w, r, &body) {
return
}
if !s.preAction(w, r, id, "remove folders without music") {
return
}
j, err := s.eng.StartRemoveFolders(id, body.Folders)
if err != nil {
opErr(w, err)
return
}
s.log.Info("removing folders without music", "pair", id, "folders", len(body.Folders))
writeJSON(w, 202, j)
}