I have an existing zip file. I am facing an error while trying to do the below using flysystem-ziparchive unzipped to a directory deleted the zip file deleted some unnecessary files in the directory create a zip with same name and same location from the directory. zip is created same like existing zip file, not with updated directory contents. if create the zip with different name or different location it is happening correctly. sample coding:
$zipAdapter = new Filesystem(new ZipArchiveAdapter($zipFile));
$localAdapter = new Filesystem(new LocalAdapter($directoryName));
//unzip to a folder
unZip($directoryName, $zipFile);
//Deleting zip file
unlink($zipFile);
$zipAdapter->createZip($directoryName);
//method to create zip
public function createZip($directory)
{
//get list of files from source
$files = $localAdapter->listContents();
//Create zip
foreach ($files as $file)
{
$zipAdapter->putStream($file['basename'], $this->local->readStream($file['basename']));
}
}