Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 0eb0a0a

Browse files
committed
Throw exception if extension doesn't exist.
Update to make extractTo() throw an exception if the Firefox extension .xpi file doesn't exist, which should be the desired behavior. Currently extractTo() only throws an error if the .xpi file exists AND is unable to open. ZipArchive throws some Warning messages when you use extractTo() and close() on an initialized ZipArchive object which is the case if the file doesn't exist.
1 parent 787e71d commit 0eb0a0a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/Firefox/FirefoxProfile.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,15 @@ private function deleteDirectory($directory) {
249249
*/
250250
private function extractTo($xpi, $target_dir) {
251251
$zip = new ZipArchive();
252-
if ($zip->open($xpi)) {
253-
$zip->extractTo($target_dir);
254-
$zip->close();
252+
if (file_exists($xpi)) {
253+
if ($zip->open($xpi)) {
254+
$zip->extractTo($target_dir);
255+
$zip->close();
256+
} else {
257+
throw new \Exception("Failed to open the firefox extension. '$xpi'");
258+
}
255259
} else {
256-
throw new \Exception("Failed to open the firefox extension. '$xpi'");
260+
throw new \Exception("Firefox extension doesn't exist. '$xpi'");
257261
}
258262
return $this;
259263
}

0 commit comments

Comments
 (0)