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

Cant delete file #127

Open
nmsobri opened this issue Mar 17, 2017 · 4 comments
Open

Cant delete file #127

nmsobri opened this issue Mar 17, 2017 · 4 comments
Labels

Comments

@nmsobri
Copy link

nmsobri commented Mar 17, 2017

Is there a way to close the file that zippy had open?

$zippy = Zippy::load();
		
#Open the archive
$archive = $zippy->open( $destination_file );
	
#List the file
$lists = array();
foreach( $archive as $member ) {
    if ( !$member->isDir() ) {
        $lists[] = $member;
    }
}
		
#Extracts the archive
$archive->extract( ROOT_PATH . 'images/upload/' );

unlink($destination_file) //<-------cant delete file, it gives error "Text file busy"
@fabre-thibaud
Copy link
Contributor

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 ?

@nmsobri
Copy link
Author

nmsobri commented Mar 17, 2017

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.

@fabre-thibaud
Copy link
Contributor

Maybe the ZIP process is not closed correctly on Windows platforms. I will try to reproduce in the same env as yours.

@filippotoso
Copy link

I solved this issue setting $archive to null before the unlink() call:

// ...

$archive->extract(__DIR__ . '/extract');

$archive = null;

unlink($archivePath);

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

No branches or pull requests

3 participants