Rebuild on file renames so deletes take effect
The watcher only reacted to Create/Write/Remove. A /manage delete moves the image and sidecar into content/.trash/, which on Linux arrives as a Rename (inotify IN_MOVED_FROM), not a Remove — so the watcher never fired and the delete left the published site unchanged (uploads worked because they Create and Write). Watch Rename too, which also covers removing a photo with a manual mv. The delete handler still triggers its own immediate rebuild; this makes the watcher path agree with it.
This commit is contained in:
1 parent
8fa1aa4cd4
commit
25384d3f3b
1 file changed
+8
-1
+8
-1
@@ -30,6 +30,12 @@ func NewWatcher(dir string, g *Generator) (*Watcher, error) {
|
||||
// Watch blocks, watching for changes and triggering rebuilds.
|
||||
// Rapid events (e.g. scp writing an image then its sidecar) are debounced
|
||||
// with a 500 ms window so only one rebuild fires per logical upload.
|
||||
//
|
||||
// Rename is watched alongside Create/Write/Remove: moving a photo out of the
|
||||
// content directory — which is exactly what a /manage delete does when it
|
||||
// sends files to content/.trash/ — arrives as a Rename (inotify IN_MOVED_FROM)
|
||||
// on Linux, not a Remove, so without it a delete (or a manual mv) would leave
|
||||
// the site unrebuilt.
|
||||
func (w *Watcher) Watch() {
|
||||
var timer *time.Timer
|
||||
rebuild := func() {
|
||||
@@ -47,7 +53,8 @@ func (w *Watcher) Watch() {
|
||||
if !isRelevant(event.Name) {
|
||||
continue
|
||||
}
|
||||
if event.Has(fsnotify.Create) || event.Has(fsnotify.Write) || event.Has(fsnotify.Remove) {
|
||||
if event.Has(fsnotify.Create) || event.Has(fsnotify.Write) ||
|
||||
event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) {
|
||||
if timer != nil {
|
||||
timer.Stop()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user