diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-10-22 12:51:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-22 12:51:47 +0200 |
commit | 2ba34cba2c571c8a3e5315b79b8a627af2079ab6 (patch) | |
tree | 40d95a7ce71e1bbe3c2c5651bfca9a6cee394420 /lib | |
parent | a7470576cfbc36da3230d6038a632e19db8669de (diff) | |
parent | d11de8c8e7a61bccd09b42cc367a02d104b70bbb (diff) | |
download | nextcloud-server-2ba34cba2c571c8a3e5315b79b8a627af2079ab6.tar.gz nextcloud-server-2ba34cba2c571c8a3e5315b79b8a627af2079ab6.zip |
Merge pull request #23608 from nextcloud/enh/23482/forward-error-message
Add more details if extract fails
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Archive/TAR.php | 10 | ||||
-rw-r--r-- | 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 0d4103299ce..bf69df0edc6 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 47d6c42d518..9388711697a 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, ['.', '..']); |