Skip to content

Commit

Permalink
Merge pull request #213 from Shopify/file_watcher_create_and_delete
Browse files Browse the repository at this point in the history
Supporting remove event in watch.
  • Loading branch information
tanema authored Oct 4, 2016
2 parents 08e8c8f + 3bd4242 commit 24284f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion commands/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func buildForeman(client kit.ThemeClient, args Args, config kit.Configuration) *
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)
}
Expand Down
5 changes: 4 additions & 1 deletion kit/file_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions kit/theme_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,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)
}

Expand Down

0 comments on commit 24284f5

Please sign in to comment.