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

Compress-Archive -Update delete archive if file could not be appended #112

Open
Platzer opened this issue Dec 16, 2021 · 2 comments
Open

Comments

@Platzer
Copy link

Platzer commented Dec 16, 2021

Description

When using Compress-Archive with -Update to append a file to an existing ZIP file, and the current file used is locked by another process the ZIP file is deleted. If it make sense or not to append an open file Compress-Archive should not remove a not empty archive.

Reproduce

# Setup test files
'Test file one content' > 'test_file_1.txt';
'Test file two content' > 'test_file_2.txt';

# Prepare file handle
$lockFile = Get-ChildItem '.\test_file_2.txt';
$lockTestFile2 = [System.IO.File]::Open($lockFile.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Write, [System.IO.FileShare]::ReadWrite)

Compress-Archive -Path .\test_file_1.txt -DestinationPath 'ZipFile.zip' -Update

# Watch ZipFile.zip disappear
Compress-Archive -Path .\test_file_2.txt -DestinationPath 'ZipFile.zip' -Update

$lockTestFile2.Dispose();
@ayousuf23 ayousuf23 modified the milestone: 2.0 Jul 5, 2022
@Chris--A
Copy link

This issue also occurs when -Path is empty:

@() | Compress-Archive -DestinationPath 'ZipFile.zip' -Update

@ayousuf23
Copy link
Contributor

I believe this issue is solved in the 2.0 preview, but I need to double check and make sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants