Commit 80fe689a authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Delete and recreate all affected directories during an artifact cache refresh (#5461)

This will ensure cleanup of any files that existed in previous versions of
the artifacts but have since been removed
parent 96ec30b8
...@@ -220,10 +220,12 @@ class MaterialFonts { ...@@ -220,10 +220,12 @@ class MaterialFonts {
Future<Null> download() { Future<Null> download() {
Status status = logger.startProgress('Downloading Material fonts...'); Status status = logger.startProgress('Downloading Material fonts...');
Directory fontsDir = cache.getArtifactDirectory(kName);
if (fontsDir.existsSync())
fontsDir.deleteSync(recursive: true);
return Cache._downloadFileToCache( return Cache._downloadFileToCache(
Uri.parse(cache.getVersionFor(kName)), Uri.parse(cache.getVersionFor(kName)), fontsDir, true
cache.getArtifactDirectory(kName),
true
).then((_) { ).then((_) {
cache.setStampFor(kName, cache.getVersionFor(kName)); cache.setStampFor(kName, cache.getVersionFor(kName));
status.stop(showElapsedTime: true); status.stop(showElapsedTime: true);
...@@ -315,28 +317,27 @@ class FlutterEngine { ...@@ -315,28 +317,27 @@ class FlutterEngine {
String engineVersion = cache.getVersionFor(kName); String engineVersion = cache.getVersionFor(kName);
String url = 'https://storage.googleapis.com/flutter_infra/flutter/$engineVersion/'; String url = 'https://storage.googleapis.com/flutter_infra/flutter/$engineVersion/';
bool allDirty = engineVersion != cache.getStampFor(kName);
Directory pkgDir = cache.getCacheDir('pkg'); Directory pkgDir = cache.getCacheDir('pkg');
for (String pkgName in _getPackageDirs()) { for (String pkgName in _getPackageDirs()) {
Directory dir = new Directory(path.join(pkgDir.path, pkgName)); Directory dir = new Directory(path.join(pkgDir.path, pkgName));
if (!dir.existsSync() || allDirty) { if (dir.existsSync())
await _downloadItem('Downloading package $pkgName...', url + pkgName + '.zip', pkgDir); dir.deleteSync(recursive: true);
} await _downloadItem('Downloading package $pkgName...', url + pkgName + '.zip', pkgDir);
} }
Directory engineDir = cache.getArtifactDirectory(kName); Directory engineDir = cache.getArtifactDirectory(kName);
if (engineDir.existsSync())
engineDir.deleteSync(recursive: true);
for (String dirName in _getEngineDirs()) { for (String dirName in _getEngineDirs()) {
Directory dir = new Directory(path.join(engineDir.path, dirName)); Directory dir = new Directory(path.join(engineDir.path, dirName));
if (!dir.existsSync() || allDirty) { await _downloadItem('Downloading engine artifacts $dirName...',
await _downloadItem('Downloading engine artifacts $dirName...', url + dirName + '/artifacts.zip', dir);
url + dirName + '/artifacts.zip', dir); File frameworkZip = new File(path.join(dir.path, 'Flutter.framework.zip'));
File frameworkZip = new File(path.join(dir.path, 'Flutter.framework.zip')); if (frameworkZip.existsSync()) {
if (frameworkZip.existsSync()) { Directory framework = new Directory(path.join(dir.path, 'Flutter.framework'));
Directory framework = new Directory(path.join(dir.path, 'Flutter.framework')); framework.createSync();
framework.createSync(); os.unzip(frameworkZip, framework);
os.unzip(frameworkZip, framework);
}
} }
} }
...@@ -344,10 +345,8 @@ class FlutterEngine { ...@@ -344,10 +345,8 @@ class FlutterEngine {
String cacheDir = toolsDir[0]; String cacheDir = toolsDir[0];
String urlPath = toolsDir[1]; String urlPath = toolsDir[1];
Directory dir = new Directory(path.join(engineDir.path, cacheDir)); Directory dir = new Directory(path.join(engineDir.path, cacheDir));
if (!dir.existsSync() || allDirty) { await _downloadItem('Downloading $cacheDir tools...', url + urlPath, dir);
await _downloadItem('Downloading $cacheDir tools...', url + urlPath, dir); _makeFilesExecutable(dir);
_makeFilesExecutable(dir);
}
} }
cache.setStampFor(kName, cache.getVersionFor(kName)); cache.setStampFor(kName, cache.getVersionFor(kName));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment