From 35fde207f61719ea4558961fd3473ef634576aaf Mon Sep 17 00:00:00 2001 From: Jixun Wu Date: Sun, 16 Jul 2023 16:20:44 +0100 Subject: [PATCH] fix: pwsh script to dump db to current dir --- .../AndroidADBPullInstruction/adb_dump.ps1 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/AndroidADBPullInstruction/adb_dump.ps1 b/src/components/AndroidADBPullInstruction/adb_dump.ps1 index 3f40ac7..726c939 100644 --- a/src/components/AndroidADBPullInstruction/adb_dump.ps1 +++ b/src/components/AndroidADBPullInstruction/adb_dump.ps1 @@ -1,11 +1,14 @@ try { - $gz_b64 = adb shell su -c "cat '{{ dir }}/{{ file }}' | gzip | base64" | Out-String - $bStream = New-Object System.IO.MemoryStream(,[System.Convert]::FromBase64String($gz_b64)) - $decoded = New-Object System.IO.Compression.GzipStream($bStream, [System.IO.Compression.CompressionMode]::Decompress) - $outFile = New-Object System.IO.FileStream("{{ file }}", [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) - $decoded.CopyTo($outFile) + $gz_b64 = adb shell su -c "cat '{{ dir }}/{{ file }}' | gzip | base64" | Out-String + $bStream = New-Object System.IO.MemoryStream(,[System.Convert]::FromBase64String($gz_b64)) + $decoded = New-Object System.IO.Compression.GzipStream($bStream, [System.IO.Compression.CompressionMode]::Decompress) + $outFile = New-Object System.IO.FileStream("${PWD}\{{ file }}", [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) + $decoded.CopyTo($outFile) +} catch { + Write-Host "遇到错误:" + Write-Host $_ } finally { - if ($outFile -ne $null) { $outFile.Dispose() } - if ($decoded -ne $null) { $decoded.Dispose() } - if ($bStream -ne $null) { $bStream.Dispose() } + if ($outFile -ne $null) { $outFile.Dispose() } + if ($decoded -ne $null) { $decoded.Dispose() } + if ($bStream -ne $null) { $bStream.Dispose() } }