Dart Documentationsystem_cacheSystemCache

SystemCache class

The system-wide cache of installed packages.

This cache contains all packages that are downloaded from the internet. Packages that are available locally (e.g. from the SDK) don't use this cache.

class SystemCache {
 /// The root directory where this package cache is located.
 final String rootDir;

 String get tempDir => path.join(rootDir, '_temp');

 /// Creates a new package cache which is backed by the given directory on the
 /// user's file system.
 SystemCache(this.rootDir);

 /// Creates a system cache and registers the standard set of sources.
 factory SystemCache.withSources(String rootDir) {
   var cache = new SystemCache(rootDir);

   return cache;
 }

 /// 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.
 String createTempDir() {
   var temp = ensureDir(tempDir);
   return io.createTempDir(path.join(temp, 'dir'));
 }

 /// Deletes the system cache's internal temp directory.
 void deleteTempDir() {
   log.fine('Clean up system cache temp directory $tempDir.');
   if (dirExists(tempDir)) deleteEntry(tempDir);
 }
}

Constructors

new SystemCache(String rootDir) #

Creates a new package cache which is backed by the given directory on the user's file system.

SystemCache(this.rootDir);

factory SystemCache.withSources(String rootDir) #

Creates a system cache and registers the standard set of sources.

factory SystemCache.withSources(String rootDir) {
 var cache = new SystemCache(rootDir);

 return cache;
}

Properties

final String rootDir #

The root directory where this package cache is located.

final String rootDir

final String tempDir #

String get tempDir => path.join(rootDir, '_temp');

Methods

String createTempDir() #

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.

String createTempDir() {
 var temp = ensureDir(tempDir);
 return io.createTempDir(path.join(temp, 'dir'));
}

void deleteTempDir() #

Deletes the system cache's internal temp directory.

void deleteTempDir() {
 log.fine('Clean up system cache temp directory $tempDir.');
 if (dirExists(tempDir)) deleteEntry(tempDir);
}