Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions administrator/components/com_installer/models/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ public function install()
return false;
}

$installType = $app->input->getWord('installtype');
if ($package === null)
{
switch ($app->input->getWord('installtype'))
switch ($installType)
{
case 'folder':
// Remember the 'Install from Directory' path.
Expand Down Expand Up @@ -127,12 +128,22 @@ public function install()
}
elseif (in_array(false, $results, true))
{
if (in_array($installType, array('upload', 'url')))
{
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
}

return false;
}

// Was the package unpacked?
if (!$package)
if (!$package || !$package['type'])
{
if (in_array($installType, array('upload', 'url')))
{
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
}

$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
return false;
}
Expand Down Expand Up @@ -226,7 +237,7 @@ protected function _getPackageFromUpload()
JFile::upload($tmp_src, $tmp_dest);

// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest);
$package = JInstallerHelper::unpack($tmp_dest, true);

return $package;
}
Expand Down Expand Up @@ -260,7 +271,6 @@ protected function _getPackageFromFolder()
if (!$type)
{
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'));
return false;
}

$package['packagefile'] = null;
Expand Down Expand Up @@ -303,6 +313,7 @@ protected function _getPackageFromUrl()
{
$url = $package_url;
}
unset($update);
}

// Download the package at the URL given
Expand All @@ -319,7 +330,7 @@ protected function _getPackageFromUrl()
$tmp_dest = $config->get('tmp_path');

// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true);

return $package;
}
Expand Down
17 changes: 13 additions & 4 deletions libraries/cms/installer/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ public static function downloadPackage($url, $target = false)
* Unpacks a file and verifies it as a Joomla element package
* Supports .gz .tar .tar.gz and .zip
*
* @param string $p_filename The uploaded package filename or install directory
* @param string $p_filename The uploaded package filename or install directory
* @param boolean $alwaysReturnArray If should return false (and leave garbage behind) or return $retval['type']=false
*
* @return mixed Array on success or boolean false on failure
*
* @since 3.1
*/
public static function unpack($p_filename)
public static function unpack($p_filename, $alwaysReturnArray = false)
{
// Path to the archive
$archivename = $p_filename;
Expand All @@ -116,6 +117,14 @@ public static function unpack($p_filename)
}
catch (Exception $e)
{
if ($alwaysReturnArray)
{
$retval['extractdir'] = null;
$retval['packagefile'] = $archivename;
$retval['type'] = false;
return $retval;
}

return false;
}

Expand Down Expand Up @@ -155,7 +164,7 @@ public static function unpack($p_filename)
*/
$retval['type'] = self::detectType($extractdir);

if ($retval['type'])
if ($retval['type'] || $alwaysReturnArray)
{
return $retval;
}
Expand Down Expand Up @@ -252,7 +261,7 @@ public static function cleanupInstall($package, $resultdir)
$config = JFactory::getConfig();

// Does the unpacked extension directory exist?
if (is_dir($resultdir))
if ($resultdir && is_dir($resultdir))
{
JFolder::delete($resultdir);
}
Expand Down