[Windows] Allow overwriting the cache's Dart SDK archive license file (#132669)
https://github.com/flutter/engine/pull/43974 added a license file to the Dart SDK's ZIP archive. As a result, extracting the Dart SDK now needs to overwrite the cache's `LICENSE.dart_sdk_archive.md` file. This is a short-term solution that will be cherry-picked for the next [3.14 beta release](https://github.com/flutter/flutter/issues/132267). Addresses https://github.com/flutter/flutter/issues/132592. The long-term solution is tracked by https://github.com/flutter/flutter/issues/132702
This commit is contained in:
@@ -18,6 +18,7 @@ $flutterRoot = (Get-Item $progName).parent.parent.FullName
|
||||
|
||||
$cachePath = "$flutterRoot\bin\cache"
|
||||
$dartSdkPath = "$cachePath\dart-sdk"
|
||||
$dartSdkLicense = "$cachePath\LICENSE.dart_sdk_archive.md"
|
||||
$engineStamp = "$cachePath\engine-dart-sdk.stamp"
|
||||
$engineVersion = (Get-Content "$flutterRoot\bin\internal\engine.version")
|
||||
$engineRealm = (Get-Content "$flutterRoot\bin\internal\engine.realm")
|
||||
@@ -49,11 +50,18 @@ if ($engineRealm) {
|
||||
$dartZipName = "dart-sdk-windows-x64.zip"
|
||||
$dartSdkUrl = "$dartSdkBaseUrl/flutter_infra_release/flutter/$engineVersion/$dartZipName"
|
||||
|
||||
if (Test-Path $dartSdkPath) {
|
||||
if ((Test-Path $dartSdkPath) -or (Test-Path $dartSdkLicense)) {
|
||||
# Move old SDK to a new location instead of deleting it in case it is still in use (e.g. by IntelliJ).
|
||||
$oldDartSdkSuffix = 1
|
||||
while (Test-Path "$cachePath\$oldDartSdkPrefix$oldDartSdkSuffix") { $oldDartSdkSuffix++ }
|
||||
Rename-Item $dartSdkPath "$oldDartSdkPrefix$oldDartSdkSuffix"
|
||||
|
||||
if (Test-Path $dartSdkPath) {
|
||||
Rename-Item $dartSdkPath "$oldDartSdkPrefix$oldDartSdkSuffix"
|
||||
}
|
||||
|
||||
if (Test-Path $dartSdkLicense) {
|
||||
Rename-Item $dartSdkLicense "$oldDartSdkPrefix$oldDartSdkSuffix.LICENSE.md"
|
||||
}
|
||||
}
|
||||
New-Item $dartSdkPath -force -type directory | Out-Null
|
||||
$dartSdkZip = "$cachePath\$dartZipName"
|
||||
@@ -98,5 +106,5 @@ If (Get-Command 7z -errorAction SilentlyContinue) {
|
||||
Remove-Item $dartSdkZip
|
||||
$engineVersion | Out-File $engineStamp -Encoding ASCII
|
||||
|
||||
# Try to delete all old SDKs.
|
||||
# Try to delete all old SDKs and license files.
|
||||
Get-ChildItem -Path $cachePath | Where {$_.BaseName.StartsWith($oldDartSdkPrefix)} | Remove-Item -Recurse -ErrorAction SilentlyContinue
|
||||
|
||||
Reference in New Issue
Block a user