-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix (decompress): Expand-7zipArchive only delete temp dir / $extractDir if it is empty
#6092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
f634ba0
6f6932c
78f7e30
501ce50
1853d24
0ecdc8d
608bb98
041ecba
46ba47b
fae981c
243fb50
c6817cf
4b4767f
1c87c6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,15 +123,21 @@ function Expand-7zipArchive { | |
| } | ||
| if (!$IsTar -and $ExtractDir) { | ||
| movedir "$DestinationPath\$ExtractDir" $DestinationPath | Out-Null | ||
| # Remove temporary directory | ||
| Remove-Item "$DestinationPath\$($ExtractDir -replace '[\\/].*')" -Recurse -Force -ErrorAction Ignore | ||
| # Remove temporary directory if it still exists and is empty | ||
| $ExtractDirFullPath = [string] "$DestinationPath\$($ExtractDir -replace '[\\/].*')" | ||
| if ( | ||
| (Test-Path -Path $ExtractDirFullPath -PathType 'Container') -and | ||
| (Get-ChildItem -Path $ExtractDirFullPath -Force).Count -eq 0 | ||
| ) { | ||
| Remove-Item -Path $ExtractDirFullPath -Recurse -Force -ErrorAction Ignore | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While testing manifests, I happened to run into an issue here. When the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So one should look for files specifically? Add
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When extraction is done, we cannot tell whether the folder is newly created or already existed. Perhaps we could check if the folder exists recursively before 7-Zip actually starts extracting?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you create a new issue with an example manifest where this problem occurs? There is also this feature request which would make this logic unnecessary:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK. I'm just about to do it.
It would be even better if this new feature fixes the issue.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| if (Test-Path $LogPath) { | ||
| Remove-Item $LogPath -Force | ||
| } | ||
| if ($Removal) { | ||
| if (($Path -replace '.*\.([^\.]*)$', '$1') -eq '001') { | ||
| # Remove splited 7-zip archive parts | ||
| # Remove splitted 7-zip archive parts | ||
| Get-ChildItem "$($Path -replace '\.[^\.]*$', '').???" | Remove-Item -Force | ||
| } elseif (($Path -replace '.*\.part(\d+)\.rar$', '$1')[-1] -eq '1') { | ||
| # Remove splitted RAR archive parts | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.