Skip to content

Commit

Permalink
#2615 Wiki: import
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Trofimov committed Dec 22, 2021
1 parent 0fca1b5 commit cd179e5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/boonex/wiki/classes/BxWikiStudioPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function getImport ()
];
$sErrorMsg = '';
$b = $this->import($aParams, $sErrorMsg);
self::removeTmpFolder();
if ($b)
return _t('_bx_wiki_import_success');
else
Expand All @@ -141,7 +142,7 @@ static public function import($aParams, &$sErrorMsg)

// empty directory to clone repository to
$sDir = BX_DIRECTORY_PATH_TMP . 'bx_wiki_import';
if (file_exists($sDir) && !bx_rrmdir($sDir)) {
if (!self::removeTmpFolder()) {
$sErrorMsg = "$sDir can't be removed";
return false;
}
Expand All @@ -151,7 +152,7 @@ static public function import($aParams, &$sErrorMsg)
$aOutput = null;
$iRetVal = null;
if (false === exec(escapeshellcmd($sCmd), $aOutput, $iRetVal) || (null !== $iRetVal && $iRetVal)) {
$sErrorMsg = "Command($sCmd) execution failed";
$sErrorMsg = "Command($sCmd) execution failed: <pre>" . implode("\n", $aOutput) . "</pre>";
return false;
}

Expand Down Expand Up @@ -350,6 +351,11 @@ static protected function processImages($sContents, $aMapPageUris, $sBaseUrlOld,
return $sContents;
}

static public function removeTmpFolder()
{
$sDir = BX_DIRECTORY_PATH_TMP . 'bx_wiki_import';
return !file_exists($sDir) || bx_rrmdir($sDir);
}
}

/** @} */

0 comments on commit cd179e5

Please sign in to comment.