Skip to content

Double update messages #16

Description

@dkorpel

I tried out watching a folder named "test" in Windows 10:

import core.thread: Thread, msecs;
import std.stdio;
import fswatch;

void main(string[] args) {
	FileWatch watcher = FileWatch("test", true);
	while(true) {
		writeln(watcher.getEvents());
		Thread.sleep(500.msecs);
	}
}

I noticed that I receive more messages than needed:

// Saving a file in notepad
[]
[FileChangeEvent(modify, "file.txt", "")]
[]
[FileChangeEvent(modify, "file.txt", "")]
[]
[]
// Saving a new file in notepad
[]
[FileChangeEvent(create, "newfile.txt", "")]
[]
[FileChangeEvent(remove, "newfile.txt", ""), FileChangeEvent(create, "newfile.txt", ""), FileChangeEvent(modify, "newfile.txt", ""), FileChangeEvent(modify, "newfile.txt", "")]
[]
// Creating a file using std.file.write
[]
[FileChangeEvent(create, "hey.txt", "")]
[]
[FileChangeEvent(modify, "hey.txt", "")]
[]

Even if I change the sleep time, it's always first an empty event array and then an array with redundant messages. I don't know if this is just how the Windows API works or if some extra modifications are being done under the hood, but it's weird how they show up only after calling getEvents() twice more.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions