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

Unified Diff: utils/pub/system_cache.dart

Issue 11151035: Download packages to temp dir inside system cache. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« utils/pub/pub.dart ('K') | « utils/pub/pub.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ });
+ }
}
« utils/pub/pub.dart ('K') | « utils/pub/pub.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698