Open nmsobri opened 7 years ago
I cannot reproduce your issue with the following code:
<?php
require_once __DIR__ . '/vendor/autoload.php';
$archivePath = 'test.zip';
copy('source.zip', $archivePath);
$zippy = Alchemy\Zippy\Zippy::load();
$archive = $zippy->open($archivePath);
$lists = array();
foreach( $archive as $member ) {
if ( !$member->isDir() ) {
$lists[] = $member;
}
}
$archive->extract(__DIR__ . '/extract');
unlink($archivePath);
Can you provide more details about the environment in which the error is occuring ?
I'm running the php code inside vagrant machine
Host : Windows 10 Guest: Ubuntu 14.04 Server : Apache2 Php : Php5.6
I'm pretty sure its somehow related to zippy not releasing file pointer to the open file. When i commented all the code related to zippy, it can delete the file.
Maybe the ZIP process is not closed correctly on Windows platforms. I will try to reproduce in the same env as yours.
I solved this issue setting $archive to null before the unlink() call:
// ...
$archive->extract(__DIR__ . '/extract');
$archive = null;
unlink($archivePath);
Is there a way to close the file that zippy had open?