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 |