PowerShell / Microsoft.PowerShell.Archive

Archive PowerShell module contains cmdlets for working with ZIP archives
https://technet.microsoft.com/en-us/library/dn818910.aspx
MIT License
94 stars 37 forks source link

`compress-archive -update` deletes an existing zip file if the -path spec returns 0 files #142

Open kaiser-roy opened 2 years ago

kaiser-roy commented 2 years ago

Prerequisites

Steps to reproduce

# make a tiny file
echo 'bibbity' > bibbity.txt

# this -path specification returns (at least) bibbity.txt and creates bobbity.zip
compress-archive -path bibbity.* -update -destinationpath bobbity.zip

# Now remove any such files
rm bibbity.*

# THIS path spec now returns nothing, and compress-archive actually deletes bobbity.zip!
compress-archive -path bibbity.* -update -destinationpath bobbity.zip

Expected behavior

The second call to compress-archive should leave the existing 'bobbity.zip' file undisturbed, but instead it completely removes it.

Actual behavior

'bobbity.zip' file is removed.

This is likely related to #112, though I think the use-case here is more general.

Error details

n/a

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

5.1.19041.1682

Visuals

No response

ayousuf23 commented 2 years ago

Thanks for reporting the bug! Since this is related to #112, which may have been solved in the latest preview, this bug might also have been solved. I will need to double check though.