Delete Chrome temp cache after closing (#119062)

* Delete Chrome temp cache after closeing

* Update packages/flutter_tools/lib/src/web/chrome.dart

Co-authored-by: Christopher Fujino <fujino@google.com>

---------

Co-authored-by: Christopher Fujino <fujino@google.com>
This commit is contained in:
Pascal Welsch 2023-02-10 18:39:58 +01:00 committed by GitHub
parent 298c874eac
commit 25c2c22d29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -222,6 +222,12 @@ class ChromiumLauncher {
if (process != null && cacheDir != null) {
unawaited(process.exitCode.whenComplete(() {
_cacheUserSessionInformation(userDataDir, cacheDir);
// cleanup temp dir
try {
userDataDir.deleteSync(recursive: true);
} on FileSystemException {
// ignore
}
}));
}
return connect(Chromium(

View File

@ -419,13 +419,6 @@ void main() {
cacheDir: dataDir,
);
exitCompleter.complete();
await Future<void>.delayed(const Duration(milliseconds: 1));
// writes non-crash back to dart_tool
expect(preferencesFile.readAsStringSync(), '"exit_type":"Normal"');
// validate any Default content is copied
final Directory defaultContentDir = fileSystem
.directory('.tmp_rand0/flutter_tools_chrome_device.rand0')
@ -434,6 +427,12 @@ void main() {
expect(defaultContentDir, exists);
exitCompleter.complete();
await Future<void>.delayed(const Duration(milliseconds: 1));
// writes non-crash back to dart_tool
expect(preferencesFile.readAsStringSync(), '"exit_type":"Normal"');
// Validate cache dirs are not copied.
for (final String cache in kCodeCache) {
expect(fileSystem
@ -441,6 +440,9 @@ void main() {
.childDirectory('Default')
.childDirectory(cache), isNot(exists));
}
// validate defaultContentDir is deleted after exit, data is in cache
expect(defaultContentDir, isNot(exists));
});
testWithoutContext('can retry launch when glibc bug happens', () async {