ZipArchive zips slow to open, Win10

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
GlennLittleford
New php-forum User
New php-forum User
Posts: 5
Joined: Sun May 19, 2019 3:49 am

Mon Oct 21, 2019 4:52 pm

Hi

I'm using the following code to zip up a MySQL dump ( text file ).

Code: Select all

$zip=new ZipArchive();
$zip->open($FileFolderLocal."Database/".$BackupName.".zip", ZipArchive::CREATE);
$zip->addFile($FileFolderLocal."Database/".$BackupName.".sql",$BackupName.".sql");
$zip->close();
where $FileFolderLocal is the local path to the folder containing the sql file and $BackupName is its name minus extension. So we end up with a zipped file of the sql file in the same folder.

The zipped up file is created, but if I then browse to that folder, click on the new zip file, or try to open it, there is a delay of 20 plus seconds before it responds. Once open, its fine, and the zipped contents are intact.

Running php 7.1.7, on Windows 10.

Any ideas why the OS is struggling to open up the zip file?

Glenn
User avatar
hyper
php-forum GURU
php-forum GURU
Posts: 852
Joined: Mon Feb 22, 2016 5:52 pm

Tue Oct 22, 2019 8:09 am

It will take some time if the file is big.

Are you doing this as a cron job?
GlennLittleford
New php-forum User
New php-forum User
Posts: 5
Joined: Sun May 19, 2019 3:49 am

Tue Oct 22, 2019 3:20 pm

Only small files, 30k. Its part of a intranet application written in php. The user can click a button that dumps the MySQL data into a .sql text file in a backup folder on the server. Then the idea was php would zip it up before sending to the client, to save space and time. If I then go to open the zip, its a major slow down, but it does eventually open and everything's fine.

Glenn
User avatar
hyper
php-forum GURU
php-forum GURU
Posts: 852
Joined: Mon Feb 22, 2016 5:52 pm

Wed Oct 23, 2019 8:35 am

At 30k, it's honestly not worth the effort; any time saved would be spent trying to work out why it takes so long, and then having to unzip it at the other end.

Out of interest, how big is the file once zipped?
GlennLittleford
New php-forum User
New php-forum User
Posts: 5
Joined: Sun May 19, 2019 3:49 am

Thu Oct 24, 2019 9:12 pm

30k zipped. About 250k not zipped. Point is, the file size doens't affect the delay it takes for Windows to open it. Another one was about 5m zipped, 23m unzipped. Took just as long for windows to respond. Other zip files not created by ZipArchive open in a flash.

Glenn
Post Reply