Chromium Code Reviews| Index: utils/pub/system_cache.dart |
| diff --git a/utils/pub/system_cache.dart b/utils/pub/system_cache.dart |
| index 1a4cdd08f4a36547ca1bb6fd43ababd8ce81bc84..a06838092a6b885f5f3b082e480d1b87adb3ceb7 100644 |
| --- a/utils/pub/system_cache.dart |
| +++ b/utils/pub/system_cache.dart |
| @@ -4,7 +4,10 @@ |
| library system_cache; |
| +import 'dart:io'; |
| + |
| import 'io.dart'; |
| +import 'io.dart' as io show createTempDir; |
| import 'package.dart'; |
| import 'source.dart'; |
| import 'source_registry.dart'; |
| @@ -23,6 +26,8 @@ class SystemCache { |
| */ |
| final String rootDir; |
| + String get tempDir => join(rootDir, '_temp'); |
| + |
| /** |
| * Packages which are currently being asynchronously installed to the cache. |
| */ |
| @@ -70,4 +75,23 @@ class SystemCache { |
| _pendingInstalls[id] = future; |
| return future; |
| } |
| + |
| + /// Create a new temporary directory within the system cache. The system |
| + /// cache maintains its own temporary directory that it uses to stage |
| + /// packages into while installing. It uses this instead of the OS's system |
| + /// temp directory to ensure that it's on the same volume as the pub system |
| + /// cache so that it can move the directory from it. |
| + Future<Directory> createTempDir() { |
| + return ensureDir(join(rootDir, '_temp')).chain((tempDir) { |
|
kasperl
2012/10/16 06:08:50
Rename tempDir variable to avoid shadowing the get
|
| + return io.createTempDir(join(tempDir, 'dir')); |
| + }); |
| + } |
| + |
| + /// Delete's the system cache's internal temp directory. |
| + Future deleteTempDir() { |
| + return dirExists(tempDir).chain((exists) { |
| + if (!exists) return new Future.immediate(null); |
| + return deleteDir(tempDir); |
| + }); |
| + } |
| } |