From d11de8c8e7a61bccd09b42cc367a02d104b70bbb Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 21 Oct 2020 16:03:40 +0200 Subject: [PATCH] Add more details if extract fails. Signed-off-by: Daniel Kesselberg --- lib/private/Archive/TAR.php | 10 ++++++++++ lib/private/Installer.php | 14 ++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/private/Archive/TAR.php b/lib/private/Archive/TAR.php index 0d4103299c..bf69df0edc 100644 --- a/lib/private/Archive/TAR.php +++ b/lib/private/Archive/TAR.php @@ -381,4 +381,14 @@ class TAR extends Archive { $types = [null, 'gz', 'bz']; $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; + } } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 47d6c42d51..9388711697 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -294,12 +294,14 @@ class Installer { if ($archive) { if (!$archive->extract($extractDir)) { - throw new \Exception( - sprintf( - 'Could not extract app %s', - $appId - ) - ); + $errorMessage = 'Could not extract app ' . $appId; + + $archiveError = $archive->getError(); + if ($archiveError instanceof \PEAR_Error) { + $errorMessage .= ': ' . $archiveError->getMessage(); + } + + throw new \Exception($errorMessage); } $allFiles = scandir($extractDir); $folders = array_diff($allFiles, ['.', '..']);