diff --git a/README.md b/README.md index 5e16c3a..a16ed13 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,14 @@ Watch a folder for new CBZ/CBR files and optimize them automatically: cbzconverter watch [folder] --quality 85 --override --format webp --split ``` +Watch mode only reacts to filesystem events that occur *after* it starts; it does not +scan and optimize files that already exist in the folder when it starts. Run the +`optimize` command first if you need to process an existing library, then use `watch` +to keep it up to date going forward. The only exception is a directory that gets +created/moved into the watched tree while watch mode is running: since no per-file +event is emitted for files already inside it, its existing archives are processed once +when the directory is first detected. + Or with Docker: ```sh diff --git a/cmd/cbzoptimizer/commands/watch_command.go b/cmd/cbzoptimizer/commands/watch_command.go index b3bcb3e..b4b7684 100644 --- a/cmd/cbzoptimizer/commands/watch_command.go +++ b/cmd/cbzoptimizer/commands/watch_command.go @@ -100,10 +100,16 @@ func WatchCommand(_ *cobra.Command, args []string) error { debouncer := newEventDebouncer(debounceDelay, queue.Enqueue) defer debouncer.Stop() + // Note: existing archives already present under path when the watch + // starts are intentionally left untouched. Watch mode only reacts to + // filesystem events going forward; use the `optimize` command to process + // a library's existing contents. Archives inside a directory that is + // created/moved into the watched tree *after* startup are still + // back-filled below, since only the directory itself generates an + // fsnotify event. if err := addRecursiveWatch(watcher, path); err != nil { return fmt.Errorf("failed to watch path %s: %w", path, err) } - backfillExistingArchives(path, debouncer.Trigger) for { select {