Skip to content
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

fix (decompress): Expand-7zipArchive only delete temp dir / $extractDir if it is empty #6092

Merged
merged 14 commits into from
Aug 9, 2024

Conversation

o-l-a-v
Copy link

@o-l-a-v o-l-a-v commented Aug 6, 2024

Description

decompress.ps1 deletes $extractDir even if it's not empty, which can cause applications to not work after installation.

More context and how I got to this solution in following comment:

Motivation and Context

Closes #6011, ScoopInstaller/Extras#13324

How Has This Been

Tested locally with scoop install extras/tor-browser.

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

@o-l-a-v
Copy link
Author

o-l-a-v commented Aug 6, 2024

If tests should be updated (tell me): Should be sufficient to add a .7z to https://github.com/ScoopInstaller/Scoop/blob/develop/test/fixtures/decompress/TestCases.zip with:

root
├─ $PLUGINSDIR
└─ keep
   └─ keep
      └─  file.txt

Then check that "$DestinationPath\keep" exists?

@o-l-a-v o-l-a-v changed the title Short term fix to #6011 fix (decompress): Short term fix to #6011 Aug 6, 2024
@niheaven
Copy link
Member

niheaven commented Aug 7, 2024

Could you please sign your commit? And the logic should be tweaked by only check if $ExtractDir is empty.

@o-l-a-v
Copy link
Author

o-l-a-v commented Aug 7, 2024

Could you please sign your commit?

I've never done that before, I'll see if I can figure how. 👍

And the logic should be tweaked by only check if $ExtractDir is empty.

Isn't that what I do? If no child items inside it => delete. It's also possible to use Test-Path -Path '<directory>\*', but I like using Get-ChildItem for readability.

I also kept $ExtractDir -replace '[\\/].*. I don't really see why it's neccessary, but I tried doing as little changes as possible.


I now see that the other Expand-*Archive functions suffers from the same bug. Or maybe they don't?

image

lib/decompress.ps1 Outdated Show resolved Hide resolved
@niheaven
Copy link
Member

niheaven commented Aug 7, 2024

@niheaven
Copy link
Member

niheaven commented Aug 7, 2024

Hmm, you should try to pass the tests now :)

@o-l-a-v
Copy link
Author

o-l-a-v commented Aug 7, 2024

I think I've fixed the test errors now @niheaven: Can't do Get-ChildItem if -Path does not exist.

lib/decompress.ps1 Outdated Show resolved Hide resolved
@niheaven niheaven changed the title fix (decompress): Short term fix to #6011 fix (decompress): Expand-7zipArchive Only delete temp dir / $extractDir if it is empty Aug 9, 2024
@niheaven niheaven changed the title fix (decompress): Expand-7zipArchive Only delete temp dir / $extractDir if it is empty fix (decompress): Expand-7zipArchive only delete temp dir / $extractDir if it is empty Aug 9, 2024
@niheaven niheaven merged commit 7f99c49 into ScoopInstaller:develop Aug 9, 2024
2 checks passed
@o-l-a-v o-l-a-v deleted the fix-6011 branch August 24, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants