summaryrefslogtreecommitdiffstats
path: root/modules-available/minilinux
diff options
context:
space:
mode:
authorSimon Rettberg2023-07-28 16:01:27 +0200
committerSimon Rettberg2023-07-28 16:01:27 +0200
commit4921931a052783914ed8a7104d40ca8868e8c646 (patch)
tree49fe5516f5ba65c832593e4a2c1e71b55ea89dc5 /modules-available/minilinux
parent[minilinux] Better error handling if list download fails (diff)
downloadslx-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.php29
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,
+ ]);
}
}
}