Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 7168052

Browse files
scheglovnatebosch
authored andcommitted
Catch FileSystemException during existsSync() on Windows. (#67)
1 parent 5022c65 commit 7168052

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.9.7+12
2+
3+
* Catch `FileSystemException` during `existsSync()` on Windows.
4+
15
# 0.9.7+11
26

37
* Fix an analysis hint.

lib/src/directory_watcher/windows.dart

+11-4
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ class _WindowsDirectoryWatcher
308308
}
309309
}
310310

311-
/// Returns one or more events that describe the change between the last known
312-
/// state of [path] and its current state on the filesystem.
311+
/// Returns zero or more events that describe the change between the last
312+
/// known state of [path] and its current state on the filesystem.
313313
///
314314
/// This returns a list whose order should be reflected in the events emitted
315315
/// to the user, unlike the batched events from [Directory.watch]. The
@@ -318,8 +318,15 @@ class _WindowsDirectoryWatcher
318318
List<FileSystemEvent> _eventsBasedOnFileSystem(String path) {
319319
var fileExisted = _files.contains(path);
320320
var dirExisted = _files.containsDir(path);
321-
var fileExists = File(path).existsSync();
322-
var dirExists = Directory(path).existsSync();
321+
322+
bool fileExists;
323+
bool dirExists;
324+
try {
325+
fileExists = File(path).existsSync();
326+
dirExists = Directory(path).existsSync();
327+
} on FileSystemException {
328+
return const <FileSystemEvent>[];
329+
}
323330

324331
var events = <FileSystemEvent>[];
325332
if (fileExisted) {

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: watcher
2-
version: 0.9.7+11
2+
version: 0.9.7+12
33

44
description: >
55
A file system watcher. It monitors changes to contents of directories and

0 commit comments

Comments
 (0)