Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: lib/src/directory_watcher/linux.dart

Issue 995623002: Fix bugs where events could be added after watchers were closed. (Closed) Base URL: git@github.com:dart-lang/watcher@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/directory_watcher/mac_os.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library watcher.directory_watcher.linux; 5 library watcher.directory_watcher.linux;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 var watcher = new _LinuxDirectoryWatcher(path); 127 var watcher = new _LinuxDirectoryWatcher(path);
128 _subWatchers[path] = watcher; 128 _subWatchers[path] = watcher;
129 129
130 // TODO(nweiz): Catch any errors here that indicate that the directory in 130 // TODO(nweiz): Catch any errors here that indicate that the directory in
131 // question doesn't exist and silently stop watching it instead of 131 // question doesn't exist and silently stop watching it instead of
132 // propagating the errors. 132 // propagating the errors.
133 _listen(watcher.events, (event) { 133 _listen(watcher.events, (event) {
134 if (isReady) _eventsController.add(event); 134 if (isReady) _eventsController.add(event);
135 }, onError: (error, stackTrace) { 135 }, onError: (error, stackTrace) {
136 _eventsController.addError(error, stackTrace); 136 _eventsController.addError(error, stackTrace);
137 _eventsController.close(); 137 close();
138 }, onDone: () { 138 }, onDone: () {
139 if (_subWatchers[path] == watcher) _subWatchers.remove(path); 139 if (_subWatchers[path] == watcher) _subWatchers.remove(path);
140 140
141 // It's possible that a directory was removed and recreated very quickly. 141 // It's possible that a directory was removed and recreated very quickly.
142 // If so, make sure we're still watching it. 142 // If so, make sure we're still watching it.
143 if (new Directory(path).existsSync()) _watchSubdir(path); 143 if (new Directory(path).existsSync()) _watchSubdir(path);
144 }); 144 });
145 145
146 // TODO(nweiz): Right now it's possible for the watcher to emit an event for 146 // TODO(nweiz): Right now it's possible for the watcher to emit an event for
147 // a file before the directory list is complete. This could lead to the user 147 // a file before the directory list is complete. This could lead to the user
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 static const DIRECTORY = const _EntryState._("directory"); 299 static const DIRECTORY = const _EntryState._("directory");
300 300
301 const _EntryState._(this._name); 301 const _EntryState._(this._name);
302 302
303 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise. 303 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise.
304 factory _EntryState(bool isDir) => 304 factory _EntryState(bool isDir) =>
305 isDir ? _EntryState.DIRECTORY : _EntryState.FILE; 305 isDir ? _EntryState.DIRECTORY : _EntryState.FILE;
306 306
307 String toString() => _name; 307 String toString() => _name;
308 } 308 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/directory_watcher/mac_os.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698