Skip to content

Commit

Permalink
windows: run TestWatchRename/rename_overwriting_existing_file (#490)
Browse files Browse the repository at this point in the history
This Skip() was added in 2013 (c825c6d) with "Windows cannot overwrite
file on rename", but it seems to work fine. os.Rename() is also
documented as "If newpath already exists and is not a directory, Rename
replaces it", so if it *doesn't* work it's a bug in os.Rename(). Maybe
os.Rename() behaved different nine years ago.
  • Loading branch information
arp242 committed Aug 5, 2022
1 parent ee33a65 commit f45391f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
11 changes: 6 additions & 5 deletions inotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,12 @@ func (w *Watcher) readEvents() {
// We don't know how many events we just read into the buffer
// While the offset points to at least one whole event...
for offset <= uint32(n-unix.SizeofInotifyEvent) {
// Point "raw" to the event in the buffer
raw := (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))

mask := uint32(raw.Mask)
nameLen := uint32(raw.Len)
var (
// Point "raw" to the event in the buffer
raw = (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
mask = uint32(raw.Mask)
nameLen = uint32(raw.Len)
)

if mask&unix.IN_Q_OVERFLOW != 0 {
select {
Expand Down
9 changes: 1 addition & 8 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ func TestWatchRename(t *testing.T) {
`},

{"rename overwriting existing file", func(t *testing.T, w *Watcher, tmp string) {
switch runtime.GOOS {
case "windows":
t.Skipf("os.Rename over existing file does not create an event on %q", runtime.GOOS)
}

touch(t, tmp, "renamed")
addWatch(t, w, tmp)

Expand All @@ -158,11 +153,9 @@ func TestWatchRename(t *testing.T) {
remove /renamed
create /renamed
# No remove event for Windows and Linux.
# No remove event for inotify; inotify just sends MOVE_SELF.
linux:
create /renamed
windows:
create /renamed
`},

{"rename watched directory", func(t *testing.T, w *Watcher, tmp string) {
Expand Down

0 comments on commit f45391f

Please sign in to comment.