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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/build_environment.dart

Issue 216593006: Don't allow overlapping source directories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart b/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
index 78a459cdd82ca4a7a51639e5b720c2bc783f1491..a332dd5e121a386a99911d1294ddab7ab8b5b510 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/build_environment.dart
@@ -18,7 +18,6 @@ import '../log.dart' as log;
import '../package.dart';
import '../package_graph.dart';
import '../sdk.dart' as sdk;
-import '../utils.dart';
import 'admin_server.dart';
import 'build_directory.dart';
import 'dart_forwarding_transformer.dart';
@@ -170,6 +169,16 @@ class BuildEnvironment {
});
}
+ // See if the new directory overlaps any existing servers.
+ var overlapping = _directories.keys.where((directory) =>
+ path.isWithin(directory, rootDirectory) ||
+ path.isWithin(rootDirectory, directory)).toList();
+
+ if (overlapping.isNotEmpty) {
+ return new Future.error(
+ new OverlappingSourceDirectoryException(overlapping));
+ }
+
var port = _basePort;
// If not using an ephemeral port, find the lowest-numbered available one.
@@ -669,6 +678,16 @@ void _log(LogEntry entry) {
}
}
+/// Exception thrown when trying to serve a new directory that overlaps one or
+/// more directories already being served.
+class OverlappingSourceDirectoryException implements Exception {
+ /// The relative paths of the directories that overlap the one that could not
+ /// be served.
+ final List<String> overlappingDirectories;
+
+ OverlappingSourceDirectoryException(this.overlappingDirectories);
+}
+
/// An enum describing different modes of constructing a [DirectoryWatcher].
abstract class WatcherType {
/// A watcher that automatically chooses its type based on the operating
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/barback/web_socket_api.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698