]> go.fuhry.dev Git - fsnotify.git/commitdiff
various fixes and improvements main v1.7.2
authorDan Fuhry <dan@fuhry.com>
Tue, 12 Dec 2023 04:49:02 +0000 (23:49 -0500)
committerDan Fuhry <dan@fuhry.com>
Tue, 12 Dec 2023 04:49:02 +0000 (23:49 -0500)
- add RawOp field
- support CLOSE events on inotify systems

.github/ISSUE_TEMPLATE/bug.yml
backend_inotify.go
cmd/fsnotify/dedup.go
cmd/fsnotify/file.go
cmd/fsnotify/main.go
cmd/fsnotify/watch.go
fsnotify.go
fsnotify_test.go
go.mod
helpers_test.go

index 88d4f93d9231dbf911590b3daf4169a5a078b8ce..f87a27e0291b641ca7bea134eb5a05472899c329 100644 (file)
@@ -37,5 +37,5 @@ body:
     validations: {"required": true}
     attributes:
       label: 'Did you try the latest main branch?'
     validations: {"required": true}
     attributes:
       label: 'Did you try the latest main branch?'
-      description: 'Please try the latest main branch as well, with e.g.:<br>`go get github.com/fsnotify/fsnotify@main`'
+      description: 'Please try the latest main branch as well, with e.g.:<br>`go get gitlab.ha.xx0r.info/dan/fsnotify@main`'
       options: ['No', 'Yes']
       options: ['No', 'Yes']
index fe5033b155b1b9b28906a896d4380a99c588e8ef..b4b06673d125e9452dc7bf8d245fb714faf97fd9 100644 (file)
@@ -359,7 +359,8 @@ func (w *Watcher) AddWith(name string, opts ...addOpt) error {
 
        var flags uint32 = unix.IN_MOVED_TO | unix.IN_MOVED_FROM |
                unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY |
 
        var flags uint32 = 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
 
        return w.watches.updatePath(name, func(existing *watch) (*watch, error) {
                if existing != nil {
 
        return w.watches.updatePath(name, func(existing *watch) (*watch, error) {
                if existing != nil {
@@ -577,5 +578,9 @@ func (w *Watcher) newEvent(name string, mask uint32) Event {
        if mask&unix.IN_ATTRIB == unix.IN_ATTRIB {
                e.Op |= Chmod
        }
        if mask&unix.IN_ATTRIB == unix.IN_ATTRIB {
                e.Op |= Chmod
        }
+       if mask&unix.IN_CLOSE_WRITE == unix.IN_CLOSE_WRITE || mask&unix.IN_CLOSE_NOWRITE == unix.IN_CLOSE_NOWRITE {
+               e.Op |= Close
+       }
+       e.RawOp = mask
        return e
 }
        return e
 }
index 67269d4480182e1879045694995b44aeb436501c..778e75a6ce7005155529487ff359c2b83877eb1c 100644 (file)
@@ -5,7 +5,7 @@ import (
        "sync"
        "time"
 
        "sync"
        "time"
 
-       "github.com/fsnotify/fsnotify"
+       "go.fuhry.dev/fsnotify"
 )
 
 // Depending on the system, a single "write" can generate many Write events; for
 )
 
 // Depending on the system, a single "write" can generate many Write events; for
index 357e693758b08922406e027e05739a66991b7dc9..967c1e790f465b1f6833871f12cc5b2d38b1e1ef 100644 (file)
@@ -4,7 +4,7 @@ import (
        "os"
        "path/filepath"
 
        "os"
        "path/filepath"
 
-       "github.com/fsnotify/fsnotify"
+       "go.fuhry.dev/fsnotify"
 )
 
 // Watch one or more files, but instead of watching the file directly it watches
 )
 
 // Watch one or more files, but instead of watching the file directly it watches
index cdd9de7224e28927f07c41a7f0a81bb03e5a47a3..31a6ff2e4f84ed9373cb6a6c2b242af2904fbdd1 100644 (file)
@@ -12,7 +12,7 @@ var usage = `
 fsnotify is a Go library to provide cross-platform file system notifications.
 This command serves as an example and debugging tool.
 
 fsnotify is a Go library to provide cross-platform file system notifications.
 This command serves as an example and debugging tool.
 
-https://github.com/fsnotify/fsnotify
+https://go.fuhry.dev/fsnotify
 
 Commands:
 
 
 Commands:
 
index 046a1331baf62ccfb7d92f952958cb5f9855c78c..37b608d23c336afbcbb985066f6346de3ee2e092 100644 (file)
@@ -1,6 +1,6 @@
 package main
 
 package main
 
-import "github.com/fsnotify/fsnotify"
+import "go.fuhry.dev/fsnotify"
 
 // This is the most basic example: it prints events to the terminal as we
 // receive them.
 
 // This is the most basic example: it prints events to the terminal as we
 // receive them.
index c230d37d05810e7a1b173ffc55689007c3bbf01a..58cf561714a4c7b7002733b647fbb677fcd5f64d 100644 (file)
@@ -30,6 +30,8 @@ type Event struct {
        // This is a bitmask and some systems may send multiple operations at once.
        // Use the Event.Has() method instead of comparing with ==.
        Op Op
        // This is a bitmask and some systems may send multiple operations at once.
        // Use the Event.Has() method instead of comparing with ==.
        Op Op
+
+       RawOp uint32
 }
 
 // Op describes a set of file operations.
 }
 
 // Op describes a set of file operations.
@@ -60,6 +62,9 @@ const (
        // get triggered very frequently by some software. For example, Spotlight
        // indexing on macOS, anti-virus software, backup software, etc.
        Chmod
        // get triggered very frequently by some software. For example, Spotlight
        // indexing on macOS, anti-virus software, backup software, etc.
        Chmod
+
+       // File was closed.
+       Close
 )
 
 // Common errors that can be reported.
 )
 
 // Common errors that can be reported.
@@ -86,6 +91,9 @@ func (o Op) String() string {
        if o.Has(Chmod) {
                b.WriteString("|CHMOD")
        }
        if o.Has(Chmod) {
                b.WriteString("|CHMOD")
        }
+       if o.Has(Close) {
+               b.WriteString("|CLOSE")
+       }
        if b.Len() == 0 {
                return "[no events]"
        }
        if b.Len() == 0 {
                return "[no events]"
        }
index 49124adb7e083032a89b0d67282fd6513f53d12c..859e2e627e721d1c6d12c2e25cb78c1ce73f1f7e 100644 (file)
@@ -16,7 +16,7 @@ import (
        "testing"
        "time"
 
        "testing"
        "time"
 
-       "github.com/fsnotify/fsnotify/internal"
+       "go.fuhry.dev/fsnotify/internal"
 )
 
 // Set soft open file limit to the maximum; on e.g. OpenBSD it's 512/1024.
 )
 
 // Set soft open file limit to the maximum; on e.g. OpenBSD it's 512/1024.
@@ -1349,16 +1349,18 @@ func TestEventString(t *testing.T) {
                want string
        }{
                {Event{}, `[no events]   ""`},
                want string
        }{
                {Event{}, `[no events]   ""`},
-               {Event{"/file", 0}, `[no events]   "/file"`},
+               {Event{"/file", 0, 0}, `[no events]   "/file"`},
 
 
-               {Event{"/file", Chmod | Create},
+               {Event{"/file", Chmod | Create, 0},
                        `CREATE|CHMOD  "/file"`},
                        `CREATE|CHMOD  "/file"`},
-               {Event{"/file", Rename},
+               {Event{"/file", Rename, 0},
                        `RENAME        "/file"`},
                        `RENAME        "/file"`},
-               {Event{"/file", Remove},
+               {Event{"/file", Remove, 0},
                        `REMOVE        "/file"`},
                        `REMOVE        "/file"`},
-               {Event{"/file", Write | Chmod},
+               {Event{"/file", Write | Chmod, 0},
                        `WRITE|CHMOD   "/file"`},
                        `WRITE|CHMOD   "/file"`},
+               {Event{"/file", Write | Close, 0},
+                       `WRITE|CLOSE   "/file"`},
        }
 
        for _, tt := range tests {
        }
 
        for _, tt := range tests {
diff --git a/go.mod b/go.mod
index 1deb88ce595dfab291dc82574ca5838b74170b0a..6e13713d60e7f44ce3f34b0d72e6272386d24f52 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/fsnotify/fsnotify
+module go.fuhry.dev/fsnotify
 
 go 1.17
 
 
 go 1.17
 
index 2051a94f3f86f07f8a9db81bea692727c746437a..8ca46a4d15bdfd06a2f08e5228910b9a4845054a 100644 (file)
@@ -12,7 +12,7 @@ import (
        "testing"
        "time"
 
        "testing"
        "time"
 
-       "github.com/fsnotify/fsnotify/internal"
+       "go.fuhry.dev/fsnotify/internal"
 )
 
 type testCase struct {
 )
 
 type testCase struct {