Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7f7687

Browse files
authored
Delete unzipped FlutterMacOS.framework before replacing artifact (#77316)
1 parent fcc0042 commit a7f7687

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

packages/flutter_tools/lib/src/cache.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ abstract class EngineCachedArtifact extends CachedArtifact {
934934
final File frameworkZip = fileSystem.file(fileSystem.path.join(dir.path, 'FlutterMacOS.framework.zip'));
935935
if (frameworkZip.existsSync()) {
936936
final Directory framework = fileSystem.directory(fileSystem.path.join(dir.path, 'FlutterMacOS.framework'));
937+
ErrorHandlingFileSystem.deleteIfExists(framework, recursive: true);
937938
framework.createSync();
938939
operatingSystemUtils.unzip(frameworkZip, framework);
939940
}

packages/flutter_tools/test/general.shard/cache_test.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,33 @@ void main() {
308308
verify(operatingSystemUtils.chmod(argThat(hasPath(dir.path)), 'a+r,a+x'));
309309
});
310310

311+
testWithoutContext('EngineCachedArtifact removes unzipped FlutterMacOS.framework before replacing', () async {
312+
final OperatingSystemUtils operatingSystemUtils = MockOperatingSystemUtils();
313+
final MockCache cache = MockCache();
314+
final FileSystem fileSystem = MemoryFileSystem.test();
315+
final Directory artifactDir = fileSystem.systemTempDirectory.createTempSync('flutter_cache_test_artifact.');
316+
final Directory downloadDir = fileSystem.systemTempDirectory.createTempSync('flutter_cache_test_download.');
317+
318+
when(cache.getArtifactDirectory(any)).thenReturn(artifactDir);
319+
when(cache.getDownloadDir()).thenReturn(downloadDir);
320+
final Directory binDir = artifactDir.childDirectory('bin_dir')..createSync();
321+
binDir.childFile('FlutterMacOS.framework.zip').createSync();
322+
final Directory unzippedFramework = binDir.childDirectory('FlutterMacOS.framework');
323+
final File staleFile = unzippedFramework.childFile('stale_file')..createSync(recursive: true);
324+
artifactDir.childFile('unused_url_path').createSync();
325+
326+
final FakeCachedArtifact artifact = FakeCachedArtifact(
327+
cache: cache,
328+
binaryDirs: <List<String>>[
329+
<String>['bin_dir', 'unused_url_path'],
330+
],
331+
requiredArtifacts: DevelopmentArtifact.universal,
332+
);
333+
await artifact.updateInner(MockArtifactUpdater(), fileSystem, operatingSystemUtils);
334+
expect(unzippedFramework, exists);
335+
expect(staleFile, isNot(exists));
336+
});
337+
311338
testWithoutContext('IosUsbArtifacts verifies executables for libimobiledevice in isUpToDateInner', () async {
312339
final FileSystem fileSystem = MemoryFileSystem.test();
313340
final Cache cache = Cache.test(fileSystem: fileSystem, processManager: FakeProcessManager.any());

0 commit comments

Comments
 (0)