Skip to content

Commit a8881f4

Browse files
committed
correctly remove temporary files when uncompressing ZIPs
1 parent 89b4cba commit a8881f4

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/Zip.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ function extract($outdir, $strip = '', $exclude = '', $include = '')
223223
}
224224
fclose($fp);
225225
gzclose($gzp);
226+
unlink($extractto); // remove temporary gz file
226227
}
227228

228229
touch($output, $fileinfo->getMtime());

tests/zip.test.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ public function test_zipextract()
140140
$this->assertFileExists($out.'/zip/foobar/testdata2.txt', "Extracted $file");
141141
$this->assertEquals(13, filesize($out.'/zip/foobar/testdata2.txt'), "Extracted $file");
142142

143+
$this->assertFileExists($out.'/zip/compressable.txt', "Extracted $file");
144+
$this->assertEquals(1836, filesize($out.'/zip/compressable.txt'), "Extracted $file");
145+
$this->assertFileNotExists($out.'/zip/compressable.txt.gz', "Extracted $file");
146+
143147
self::rdelete($out);
144148
}
145149

tests/zip/test.zip

343 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)