Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting remove event in watch. #213

Merged
merged 2 commits into from
Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commands/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here, with the placement of &

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is a bitwise AND, because the OP can be several different ops. You need to check it this way to be acurate. Check this out: https://github.com/fsnotify/fsnotify/blob/master/fsnotify.go#L37

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think it's just the spacing is off?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go fmt formats it this way. I have my vim setup so that is formats on save.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes total sense. The spacing is just unusual looking

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 @@ -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)
}

Expand Down