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

Add inotify CLOSE events #298

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions fsnotify.go
Expand Up @@ -29,6 +29,8 @@ const (
Remove
Rename
Chmod
Update
Close
)

func (op Op) String() string {
Expand All @@ -50,6 +52,13 @@ func (op Op) String() string {
if op&Chmod == Chmod {
buffer.WriteString("|CHMOD")
}
if op&Update == Update {
buffer.WriteString("|UPDATE")
}
if op&Close == Close {
buffer.WriteString("|CLOSE")
}

if buffer.Len() == 0 {
return ""
}
Expand Down
10 changes: 9 additions & 1 deletion inotify.go
Expand Up @@ -96,7 +96,8 @@ func (w *Watcher) Add(name string) error {

const agnosticEvents = unix.IN_MOVED_TO | unix.IN_MOVED_FROM |
unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY |
unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF
unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF | unix.IN_CLOSE_WRITE |
unix.IN_CLOSE_NOWRITE

var flags uint32 = agnosticEvents

Expand Down Expand Up @@ -333,5 +334,12 @@ func newEvent(name string, mask uint32) Event {
if mask&unix.IN_ATTRIB == unix.IN_ATTRIB {
e.Op |= Chmod
}
if mask&unix.IN_CLOSE_WRITE == unix.IN_CLOSE_WRITE || mask&unix.IN_MOVED_TO == unix.IN_MOVED_TO {
e.Op |= Update
}
if mask&unix.IN_CLOSE_WRITE == unix.IN_CLOSE_WRITE || mask&unix.IN_CLOSE_NOWRITE == unix.IN_CLOSE_NOWRITE {
e.Op |= Close
}

return e
}