Unverified Commit 25c2c22d authored by Pascal Welsch's avatar Pascal Welsch Committed by GitHub

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: 's avatarChristopher Fujino <fujino@google.com>

---------
Co-authored-by: 's avatarChristopher Fujino <fujino@google.com>
parent 298c874e
...@@ -222,6 +222,12 @@ class ChromiumLauncher { ...@@ -222,6 +222,12 @@ class ChromiumLauncher {
if (process != null && cacheDir != null) { if (process != null && cacheDir != null) {
unawaited(process.exitCode.whenComplete(() { unawaited(process.exitCode.whenComplete(() {
_cacheUserSessionInformation(userDataDir, cacheDir); _cacheUserSessionInformation(userDataDir, cacheDir);
// cleanup temp dir
try {
userDataDir.deleteSync(recursive: true);
} on FileSystemException {
// ignore
}
})); }));
} }
return connect(Chromium( return connect(Chromium(
......
...@@ -419,13 +419,6 @@ void main() { ...@@ -419,13 +419,6 @@ void main() {
cacheDir: dataDir, 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 // validate any Default content is copied
final Directory defaultContentDir = fileSystem final Directory defaultContentDir = fileSystem
.directory('.tmp_rand0/flutter_tools_chrome_device.rand0') .directory('.tmp_rand0/flutter_tools_chrome_device.rand0')
...@@ -434,6 +427,12 @@ void main() { ...@@ -434,6 +427,12 @@ void main() {
expect(defaultContentDir, exists); 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. // Validate cache dirs are not copied.
for (final String cache in kCodeCache) { for (final String cache in kCodeCache) {
expect(fileSystem expect(fileSystem
...@@ -441,6 +440,9 @@ void main() { ...@@ -441,6 +440,9 @@ void main() {
.childDirectory('Default') .childDirectory('Default')
.childDirectory(cache), isNot(exists)); .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 { testWithoutContext('can retry launch when glibc bug happens', () async {
......
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