mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2026-07-21 19:05:39 +02:00
fix(watch): don't backfill existing archives at watch startup
Co-authored-by: Belphemur <197810+Belphemur@users.noreply.github.com>
This commit is contained in:
co-authored by
Belphemur
parent
52c93acd35
commit
0b3c3fa90c
@@ -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
|
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:
|
Or with Docker:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
@@ -100,10 +100,16 @@ func WatchCommand(_ *cobra.Command, args []string) error {
|
|||||||
debouncer := newEventDebouncer(debounceDelay, queue.Enqueue)
|
debouncer := newEventDebouncer(debounceDelay, queue.Enqueue)
|
||||||
defer debouncer.Stop()
|
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 {
|
if err := addRecursiveWatch(watcher, path); err != nil {
|
||||||
return fmt.Errorf("failed to watch path %s: %w", path, err)
|
return fmt.Errorf("failed to watch path %s: %w", path, err)
|
||||||
}
|
}
|
||||||
backfillExistingArchives(path, debouncer.Trigger)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in New Issue
Block a user