diff options
author | Simon Rettberg | 2023-07-28 16:01:27 +0200 |
---|---|---|
committer | Simon Rettberg | 2023-07-28 16:01:27 +0200 |
commit | 4921931a052783914ed8a7104d40ca8868e8c646 (patch) | |
tree | 49fe5516f5ba65c832593e4a2c1e71b55ea89dc5 /modules-available/minilinux | |
parent | [minilinux] Better error handling if list download fails (diff) | |
download | slx-admin-4921931a052783914ed8a7104d40ca8868e8c646.tar.gz slx-admin-4921931a052783914ed8a7104d40ca8868e8c646.tar.xz slx-admin-4921931a052783914ed8a7104d40ca8868e8c646.zip |
[minilinux] Only create new branch if it contains any versions
Diffstat (limited to 'modules-available/minilinux')
-rw-r--r-- | modules-available/minilinux/inc/minilinux.inc.php | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/modules-available/minilinux/inc/minilinux.inc.php b/modules-available/minilinux/inc/minilinux.inc.php index 44e8bacb..1124aa65 100644 --- a/modules-available/minilinux/inc/minilinux.inc.php +++ b/modules-available/minilinux/inc/minilinux.inc.php @@ -83,20 +83,31 @@ class MiniLinux if (!self::isValidIdPart($system['id'])) continue; $branchid = $sourceid . '/' . $system['id']; - $title = empty($system['title']) ? $branchid : $system['title']; + $title = mb_substr(empty($system['title']) ? $branchid : $system['title'], 0, 150); $description = $system['description'] ?? ''; $color = $system['color'] ?? ''; - Database::exec('INSERT INTO minilinux_branch (branchid, sourceid, title, color, description) + if (!empty($system['versions']) && is_array($system['versions'])) { + Database::exec('INSERT INTO minilinux_branch (branchid, sourceid, title, color, description) VALUES (:branchid, :sourceid, :title, :color, :description) ON DUPLICATE KEY UPDATE title = VALUES(title), color = VALUES(color), description = VALUES(description)', [ - 'branchid' => $branchid, - 'sourceid' => $sourceid, - 'title' => mb_substr($title, 0, 150), - 'color' => $color, - 'description' => $description, - ]); - if (@is_array($system['versions'])) { + 'branchid' => $branchid, + 'sourceid' => $sourceid, + 'title' => $title, + 'color' => $color, + 'description' => $description, + ]); self::addVersions($branchid, $system['versions']); + } else { + // Empty branch - only update metadata if branch exists locally + Database::exec('UPDATE minilinux_branch + SET title = :title, color = :color, description = :description + WHERE sourceid = :sourceid AND branchid = :branchid', [ + 'branchid' => $branchid, + 'sourceid' => $sourceid, + 'title' => $title, + 'color' => $color, + 'description' => $description, + ]); } } } |