Add more details if extract fails.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2020-10-21 16:03:40 +02:00
parent 38bb40cffa
commit d11de8c8e7
No known key found for this signature in database
GPG Key ID: 36E3664E099D0614
2 changed files with 18 additions and 6 deletions

View File

@ -381,4 +381,14 @@ class TAR extends Archive {
$types = [null, 'gz', 'bz']; $types = [null, 'gz', 'bz'];
$this->tar = new \Archive_Tar($this->path, $types[self::getTarType($this->path)]); $this->tar = new \Archive_Tar($this->path, $types[self::getTarType($this->path)]);
} }
/**
* Get error object from archive_tar.
*/
public function getError(): ?\PEAR_Error {
if ($this->tar instanceof \Archive_Tar && $this->tar->error_object instanceof \PEAR_Error) {
return $this->tar->error_object;
}
return null;
}
} }

View File

@ -294,12 +294,14 @@ class Installer {
if ($archive) { if ($archive) {
if (!$archive->extract($extractDir)) { if (!$archive->extract($extractDir)) {
throw new \Exception( $errorMessage = 'Could not extract app ' . $appId;
sprintf(
'Could not extract app %s', $archiveError = $archive->getError();
$appId if ($archiveError instanceof \PEAR_Error) {
) $errorMessage .= ': ' . $archiveError->getMessage();
); }
throw new \Exception($errorMessage);
} }
$allFiles = scandir($extractDir); $allFiles = scandir($extractDir);
$folders = array_diff($allFiles, ['.', '..']); $folders = array_diff($allFiles, ['.', '..']);