[flutter_tools] skip copying 1GB of data from chrome cache dirs (#81170)
* [flutter_tools] skip copying 1GB of data from chrome cache dirs * Update chrome.dart
This commit is contained in:
@@ -6,6 +6,7 @@ import 'dart:async';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
@@ -99,6 +100,25 @@ void main() {
|
||||
expect(destination.childFile('a.txt').existsSync(), isFalse);
|
||||
expect(destination.childDirectory('nested').childFile('a.txt').existsSync(), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('Skip directories if shouldCopyDirectory returns false', () {
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Directory origin = fileSystem.directory('/origin');
|
||||
origin.createSync();
|
||||
fileSystem.file(fileSystem.path.join('origin', 'a.txt')).writeAsStringSync('irrelevant');
|
||||
fileSystem.directory('/origin/nested').createSync();
|
||||
fileSystem.file(fileSystem.path.join('origin', 'nested', 'a.txt')).writeAsStringSync('irrelevant');
|
||||
fileSystem.file(fileSystem.path.join('origin', 'nested', 'b.txt')).writeAsStringSync('irrelevant');
|
||||
|
||||
final Directory destination = fileSystem.directory('/destination');
|
||||
copyDirectory(origin, destination, shouldCopyDirectory: (Directory directory) {
|
||||
return !directory.path.endsWith('nested');
|
||||
});
|
||||
|
||||
expect(destination, exists);
|
||||
expect(destination.childDirectory('nested'), isNot(exists));
|
||||
expect(destination.childDirectory('nested').childFile('b.txt'),isNot(exists));
|
||||
});
|
||||
});
|
||||
|
||||
group('escapePath', () {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
@@ -26,6 +27,12 @@ const List<String> kChromeArgs = <String>[
|
||||
'--disable-translate',
|
||||
];
|
||||
|
||||
const List<String> kCodeCache = <String>[
|
||||
'Cache',
|
||||
'Code Cache',
|
||||
'GPUCache',
|
||||
];
|
||||
|
||||
const String kDevtoolsStderr = '\n\nDevTools listening\n\n';
|
||||
|
||||
void main() {
|
||||
@@ -351,7 +358,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('can seed chrome temp directory with existing session data', () async {
|
||||
testWithoutContext('can seed chrome temp directory with existing session data, excluding Cache folder', () async {
|
||||
final Completer<void> exitCompleter = Completer<void>.sync();
|
||||
final Directory dataDir = fileSystem.directory('chrome-stuff');
|
||||
final File preferencesFile = dataDir
|
||||
@@ -362,9 +369,16 @@ void main() {
|
||||
..writeAsStringSync('"exit_type":"Crashed"');
|
||||
|
||||
final Directory defaultContentDirectory = dataDir
|
||||
.childDirectory('Default')
|
||||
.childDirectory('Foo');
|
||||
defaultContentDirectory.createSync(recursive: true);
|
||||
// Create Cache directories that should be skipped
|
||||
for (final String cache in kCodeCache) {
|
||||
dataDir
|
||||
.childDirectory('Default')
|
||||
.childDirectory('Foo');
|
||||
defaultContentDirectory.createSync(recursive: true);
|
||||
.childDirectory(cache)
|
||||
.createSync(recursive: true);
|
||||
}
|
||||
|
||||
processManager.addCommand(FakeCommand(
|
||||
command: const <String>[
|
||||
@@ -397,7 +411,15 @@ void main() {
|
||||
.childDirectory('Default')
|
||||
.childDirectory('Foo');
|
||||
|
||||
expect(defaultContentDir.existsSync(), true);
|
||||
expect(defaultContentDir, exists);
|
||||
|
||||
// Validate cache dirs are not copied.
|
||||
for (final String cache in kCodeCache) {
|
||||
expect(fileSystem
|
||||
.directory('.tmp_rand0/flutter_tools_chrome_device.rand0')
|
||||
.childDirectory('Default')
|
||||
.childDirectory(cache), isNot(exists));
|
||||
}
|
||||
});
|
||||
|
||||
testWithoutContext('can retry launch when glibc bug happens', () async {
|
||||
|
||||
Reference in New Issue
Block a user