Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Get-ChocolateyUnzip captures files that don't belong to the package #616
Under some conditions (probably on fast computers with slow storage), Get-ChocolateyUnzip and Write-FileUpdateLog capture files that don't actually belong to the package, list them in the chocolatey\libInstall.zip.txt file, and cause them to be removed upon uninstall via UnInstall-ChocolateyZipPackage. This can remove arbitrary files from the users' computer!
I think this happens when you install multiple packages, and the files created by the previous package don't appear immediately in directory-listings (i.e. Get-ChildItem in Write-FileUpdateLog), but do appear when the next package has been unzipped completely, and then get listed as belonging to that package. This of course only applies, if the $locationToMonitor for Write-FileUpdateLog contains other files that don't belong to the package, which happens in scenarios where multiple packages install files into the same directory, like plugins for an eclipse installation or a UNIX-like directory structure (e.g. Cygwin, MinGW).
I think it's generally a bad idea to monitor the file system for changes to find out what files are created by 7-Zip, because other applications might modify files and big directory trees might get scanned (possibly related: #154 ).
I made a fix for Get-ChocolateyUnzip that captures 7z's standard output to determine the files created by it, and record them in the Install.zip.txt . This should always precisely capture the unzipped files and might even be faster. The stdout is printed via Write-Debug. I will submit a pull request once i figure out how to use GitHub :-)
Sometimes, Install-ChocolateyZipPackage and Get-ChocolateyUnzip capture files that don't belong to the package, record them in the <packagename>Install.zip.txt file, and cause them to be removed upon uninstallation by UnInstall-ChocolateyZipPackage. This fix uses 7z's standard output instead to determine which files belong to the package. This also avoids scanning possibly large directory trees.
Sometimes, Install-ChocolateyZipPackage and Get-ChocolateyUnzip capture files that don't belong to the package, record them in the <packagename>Install.zip.txt file, and cause them to be removed upon uninstallation by UnInstall-ChocolateyZipPackage. Instead use 7z's standard output to determine which files belong to the package. This also avoids scanning possibly large directory trees. This also resolves GH-476 by suppressing 7z's output as verbose.
When using a 32-bit version of 7z.exe to install applications, it can be subject to file system redirection. This was originally handled since 0.9.8.24 with chocolatey-archive/chocolatey@54985d5 but was later accidentally reverted in choco v0.9.10 - GH-616 (bde0941). With redirection, calls in 32bit processes to C:\Windows\System32 are automatically redirected to C:\Windows\SysWOW64. This can have undesirable effects when the path is meant to look for System32. Windows provides `SysNative` for this reason, and it should be used if the path is found (32bit processes on 64bit Windows). This puts the old behavior back to how it worked prior to the changes in 0.9.10.