From 06b393bd33811aaf9ce1e1fa41b83146da891035 Mon Sep 17 00:00:00 2001 From: Tim Anema Date: Tue, 4 Oct 2016 16:08:31 -0400 Subject: [PATCH 1/2] Supporting remove event in watch --- commands/watch.go | 2 +- kit/file_watcher.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/watch.go b/commands/watch.go index 2c5f9b9b..69b8fbe6 100644 --- a/commands/watch.go +++ b/commands/watch.go @@ -45,7 +45,7 @@ func constructFileWatcher(dir string, config kit.Configuration) chan kit.AssetEv func spawnWorker(queue chan kit.AssetEvent, client kit.ThemeClient) { for { asset := <-queue - if asset.Asset().IsValid() { + if asset.Asset().IsValid() || asset.Type() == kit.Remove { client.Message("Received %s event on %s", kit.GreenText(asset.Type().String()), kit.BlueText(asset.Asset().Key)) client.Perform(asset) } diff --git a/kit/file_watcher.go b/kit/file_watcher.go index c78b0e1c..38bb87ea 100644 --- a/kit/file_watcher.go +++ b/kit/file_watcher.go @@ -156,9 +156,12 @@ func convertFsEvents(events chan fsnotify.Event, filter EventFilter) chan AssetE recordedEvents := map[string]fsnotify.Event{} for { currentEvent = <-events + if currentEvent.Op&fsnotify.Chmod != fsnotify.Chmod { + recordedEvents[currentEvent.Name] = currentEvent + } select { case currentEvent = <-events: - if currentEvent.Op == fsnotify.Chmod { + if currentEvent.Op&fsnotify.Chmod == fsnotify.Chmod { continue } recordedEvents[currentEvent.Name] = currentEvent From 3bd424239ea62762fa99e75f9e42cbe2e48e609e Mon Sep 17 00:00:00 2001 From: Tim Anema Date: Tue, 4 Oct 2016 16:37:08 -0400 Subject: [PATCH 2/2] take out useless code --- kit/theme_client.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kit/theme_client.go b/kit/theme_client.go index f2761f39..d088e266 100644 --- a/kit/theme_client.go +++ b/kit/theme_client.go @@ -261,10 +261,6 @@ func (t ThemeClient) Perform(asset AssetEvent) { } resp, err := t.request(asset, event) - if err == nil { - defer resp.Body.Close() - } - t.eventLog <- NewAPIAssetEvent(resp, asset, err) }