Skip to content
Snippets Groups Projects
Commit 8c3edd4e authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

CI Webgui: fix loop while deleting a project

parent 630f26e6
Branches
No related tags found
No related merge requests found
......@@ -545,14 +545,18 @@ class project extends base {
* @return array
*/
public function cleanupArchive($bDeleteAll = false) {
$aUnused = array();
if (!$this->oUser->hasPermission("project-action-cleanup")){
return $this->oUser->showDenied();
}
$aDelete = array();
$aUnused = array();
$sDir = $this->_getProjectArchiveDir();
$this->getVersions();
if (!$this->_aVersions){
return $aDelete;
}
$aDelete = array();
// find unused versions
foreach ($this->_aVersions as $sVersion => $aUsage) {
if (!$aUsage || count($aUsage) == 0) {
......@@ -562,14 +566,20 @@ class project extends base {
// keep a few
$iKeep = $bDeleteAll ? 0 : $this->_aConfig["versionsToKeep"];
while (count($aUnused) >= $iKeep) {
while (count($aUnused) && count($aUnused) >= $iKeep) {
$sVersion = array_shift($aUnused);
$sDir2 = $sDir . '/' . $sVersion;
if (is_dir($sDir2)){
if ($this->_rmdir($sDir2)) {
$aDelete[] = $sDir2;
echo t('ok').': '.$sDir2;
} else {
echo t("class-project-warning-cannot-delete-archive-dir", $sDir2);
};
echo sprintf(t("class-project-warning-cannot-delete-archive-dir"), $sDir2);
}
} else {
echo t('skip').': '.$sDir2;
}
echo '<br>';
}
// rescan versions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment