Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/CI-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
ls -l build

ls -l build\\RelWithDebInfo
- name: Enable NTFS last access updates
if: ${{ matrix.config.arch != 'arm64' }}
run: fsutil behavior set disablelastaccess 0
- name: platform_output_a
if: ${{ matrix.config.arch != 'arm64' }}
shell: cmd
Expand Down Expand Up @@ -129,6 +132,8 @@ jobs:
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: mingw-${{ matrix.config.arch }}
- name: Enable NTFS last access updates
run: fsutil behavior set disablelastaccess 0
- name: Test
shell: cmd
run: |
Expand Down
2 changes: 0 additions & 2 deletions src/win/fs-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ static void uv__fs_event_queue_readdirchanges(uv_loop_t* loop,
FILE_NOTIFY_CHANGE_ATTRIBUTES |
FILE_NOTIFY_CHANGE_SIZE |
FILE_NOTIFY_CHANGE_LAST_WRITE |
FILE_NOTIFY_CHANGE_LAST_ACCESS |
FILE_NOTIFY_CHANGE_CREATION |
FILE_NOTIFY_CHANGE_SECURITY,
NULL,
Expand Down Expand Up @@ -393,7 +392,6 @@ int uv_fs_event_start(uv_fs_event_t* handle,
FILE_NOTIFY_CHANGE_ATTRIBUTES |
FILE_NOTIFY_CHANGE_SIZE |
FILE_NOTIFY_CHANGE_LAST_WRITE |
FILE_NOTIFY_CHANGE_LAST_ACCESS |
FILE_NOTIFY_CHANGE_CREATION |
FILE_NOTIFY_CHANGE_SECURITY,
NULL,
Expand Down
97 changes: 97 additions & 0 deletions test/test-fs-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,103 @@ TEST_IMPL(fs_event_watch_dir_recursive_burst) {
#endif
}

#ifdef _WIN32
#define ACCESS_DIR "watch_dir_access"
#define ACCESS_STALE ACCESS_DIR "/stale"
#define ACCESS_MARKER ACCESS_DIR "/marker"

static void fs_event_cb_access(uv_fs_event_t* handle,
const char* filename,
int events,
int status) {
ASSERT_OK(status);
ASSERT_EQ(UV_CHANGE, events);
/* Events arrive in order, so a reported read would come before this. */
ASSERT_STR_EQ(filename, "marker");
++fs_event_cb_called;
uv_close((uv_handle_t*) handle, close_cb);
}

static void access_delete_files(void) {
delete_file(ACCESS_STALE);
delete_file(ACCESS_MARKER);
delete_dir(ACCESS_DIR);
}
#endif

TEST_IMPL(fs_event_watch_dir_ignore_access) {
#ifndef _WIN32
RETURN_SKIP("Tests the Windows ReadDirectoryChangesW filter.");
#else
uv_loop_t* loop;
uv_fs_t req;
uv_file file;
uv_buf_t buf;
char data[4];
double atime;
double mtime;
int r;

loop = uv_default_loop();
access_delete_files();
create_dir(ACCESS_DIR);
create_file(ACCESS_STALE);
touch_file(ACCESS_STALE);
create_file(ACCESS_MARKER);

/* NTFS only writes the access time back once the stored one is more than
an hour old. */
r = uv_fs_stat(NULL, &req, ACCESS_STALE, NULL);
ASSERT_OK(r);
mtime = req.statbuf.st_mtim.tv_sec + req.statbuf.st_mtim.tv_nsec / 1e9;
atime = mtime - 2 * 3600;
uv_fs_req_cleanup(&req);
r = uv_fs_utime(NULL, &req, ACCESS_STALE, atime, mtime, NULL);
ASSERT_OK(r);
uv_fs_req_cleanup(&req);

r = uv_fs_event_init(loop, &fs_event);
ASSERT_OK(r);
r = uv_fs_event_start(&fs_event, fs_event_cb_access, ACCESS_DIR, 0);
ASSERT_OK(r);

r = uv_fs_open(NULL, &req, ACCESS_STALE, UV_FS_O_RDONLY, 0, NULL);
ASSERT_GE(r, 0);
file = r;
uv_fs_req_cleanup(&req);
buf = uv_buf_init(data, sizeof(data));
r = uv_fs_read(NULL, &req, file, &buf, 1, -1, NULL);
ASSERT_GT(r, 0);
uv_fs_req_cleanup(&req);
r = uv_fs_close(NULL, &req, file, NULL);
ASSERT_OK(r);
uv_fs_req_cleanup(&req);

r = uv_fs_stat(NULL, &req, ACCESS_STALE, NULL);
ASSERT_OK(r);
if (req.statbuf.st_atim.tv_sec < (long) (mtime - 3600)) {
uv_fs_req_cleanup(&req);
uv_close((uv_handle_t*) &fs_event, close_cb);
uv_run(loop, UV_RUN_DEFAULT);
access_delete_files();
MAKE_VALGRIND_HAPPY(loop);
RETURN_SKIP("Last access time updates are disabled.");
}
uv_fs_req_cleanup(&req);

touch_file(ACCESS_MARKER);
uv_run(loop, UV_RUN_DEFAULT);

ASSERT_EQ(1, fs_event_cb_called);
ASSERT_EQ(1, close_cb_called);

access_delete_files();

MAKE_VALGRIND_HAPPY(loop);
return 0;
#endif
}

#ifdef _WIN32
static char short_path_file[MAX_PATH];

Expand Down
2 changes: 2 additions & 0 deletions test/test-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ TEST_DECLARE (fs_event_watch_delete_dir_win)
#endif
TEST_DECLARE (fs_event_watch_dir_recursive)
TEST_DECLARE (fs_event_watch_dir_recursive_burst)
TEST_DECLARE (fs_event_watch_dir_ignore_access)
#ifdef _WIN32
TEST_DECLARE (fs_event_watch_dir_short_path)
#endif
Expand Down Expand Up @@ -1243,6 +1244,7 @@ TASK_LIST_START
#endif
TEST_ENTRY (fs_event_watch_dir_recursive)
TEST_ENTRY (fs_event_watch_dir_recursive_burst)
TEST_ENTRY (fs_event_watch_dir_ignore_access)
#ifdef _WIN32
TEST_ENTRY (fs_event_watch_dir_short_path)
#endif
Expand Down
Loading