Remove the old canvaskit artifacts to not confuse the web runner. (#124641)

Remove the old canvaskit artifacts to not confuse the web runner.
This commit is contained in:
Jackson Gardner
2023-04-12 09:57:41 -07:00
committed by GitHub
parent e68086e910
commit ac9b501dc2
2 changed files with 58 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ class FlutterCache extends Cache {
registerArtifact(AndroidInternalBuildArtifacts(this));
registerArtifact(IOSEngineArtifacts(this, platform: platform));
registerArtifact(FlutterWebSdk(this));
registerArtifact(LegacyCanvasKitRemover(this));
registerArtifact(FlutterSdk(this, platform: platform));
registerArtifact(WindowsEngineArtifacts(this, platform: platform));
registerArtifact(MacOSEngineArtifacts(this, platform: platform));
@@ -184,6 +185,38 @@ class FlutterWebSdk extends CachedArtifact {
}
}
// In previous builds, CanvasKit artifacts were stored in a different location
// than they are now. Leaving those old artifacts in the cache confuses the
// in-memory filesystem that the web runner uses, so this artifact will evict
// them from our cache if they are there.
class LegacyCanvasKitRemover extends ArtifactSet {
LegacyCanvasKitRemover(this.cache) : super(DevelopmentArtifact.web);
final Cache cache;
@override
String get name => 'legacy_canvaskit_remover';
Directory _getLegacyCanvasKitDirectory(FileSystem fileSystem) =>
fileSystem.directory(fileSystem.path.join(
cache.getRoot().path,
'canvaskit',
));
@override
Future<bool> isUpToDate(FileSystem fileSystem) async =>
!(await _getLegacyCanvasKitDirectory(fileSystem).exists());
@override
Future<void> update(
ArtifactUpdater artifactUpdater,
Logger logger,
FileSystem fileSystem,
OperatingSystemUtils operatingSystemUtils,
{bool offline = false}
) => _getLegacyCanvasKitDirectory(fileSystem).delete(recursive: true);
}
/// A cached artifact containing the dart:ui source code.
class FlutterSdk extends EngineCachedArtifact {
FlutterSdk(Cache cache, {