mirror of
https://github.com/flutter/flutter
synced 2024-10-12 11:12:54 +00:00
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:
parent
e68086e910
commit
ac9b501dc2
|
@ -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, {
|
||||
|
|
|
@ -880,6 +880,31 @@ void main() {
|
|||
));
|
||||
});
|
||||
|
||||
testWithoutContext('LegacyCanvasKitRemover removes old canvaskit artifacts if they exist', () async {
|
||||
final FileExceptionHandler handler = FileExceptionHandler();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test(opHandle: handler.opHandle);
|
||||
final Cache cache = Cache.test(processManager: FakeProcessManager.any(), fileSystem: fileSystem);
|
||||
final File canvasKitWasm = fileSystem.file(fileSystem.path.join(
|
||||
cache.getRoot().path,
|
||||
'canvaskit',
|
||||
'canvaskit.wasm',
|
||||
));
|
||||
canvasKitWasm.createSync(recursive: true);
|
||||
canvasKitWasm.writeAsStringSync('hello world');
|
||||
|
||||
final LegacyCanvasKitRemover remover = LegacyCanvasKitRemover(cache);
|
||||
expect(await remover.isUpToDate(fileSystem), false);
|
||||
await remover.update(
|
||||
FakeArtifactUpdater(),
|
||||
BufferLogger.test(),
|
||||
fileSystem,
|
||||
FakeOperatingSystemUtils(),
|
||||
);
|
||||
expect(await remover.isUpToDate(fileSystem), true);
|
||||
|
||||
expect(canvasKitWasm.existsSync(), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('Cache handles exception thrown if stamp file cannot be parsed', () {
|
||||
final FileExceptionHandler exceptionHandler = FileExceptionHandler();
|
||||
final FileSystem fileSystem = MemoryFileSystem.test(opHandle: exceptionHandler.opHandle);
|
||||
|
|
Loading…
Reference in a new issue