Merge pull request #23608 from nextcloud/enh/23482/forward-error-message

Add more details if extract fails
This commit is contained in:
Morris Jobke 2020-10-22 12:51:47 +02:00 committed by GitHub
commit 2ba34cba2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View file

@ -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;
}
}

View file

@ -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, ['.', '..']);