From 549e189059de9ee8c40eccd0aef9c1859b9a569a Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Sat, 24 Jan 2026 14:27:58 +0100 Subject: [PATCH] fix(luci-gitea): Fix list_repos subshell bug causing empty repos - Piped while loop runs in subshell, JSON additions don't persist - Use temp file + redirect to avoid subshell issue - Also fix list_backups with same pattern - Bumped release to r2 Co-Authored-By: Claude Opus 4.5 --- package/secubox/luci-app-gitea/Makefile | 2 +- .../luci-app-gitea/root/usr/libexec/rpcd/luci.gitea | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package/secubox/luci-app-gitea/Makefile b/package/secubox/luci-app-gitea/Makefile index ece89ac0..d0900294 100644 --- a/package/secubox/luci-app-gitea/Makefile +++ b/package/secubox/luci-app-gitea/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-gitea PKG_VERSION:=1.0.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_ARCH:=all PKG_LICENSE:=Apache-2.0 diff --git a/package/secubox/luci-app-gitea/root/usr/libexec/rpcd/luci.gitea b/package/secubox/luci-app-gitea/root/usr/libexec/rpcd/luci.gitea index 0b88b701..0b4598fe 100644 --- a/package/secubox/luci-app-gitea/root/usr/libexec/rpcd/luci.gitea +++ b/package/secubox/luci-app-gitea/root/usr/libexec/rpcd/luci.gitea @@ -362,7 +362,12 @@ list_repos() { local repo_root="$data_path/git/repositories" if [ -d "$repo_root" ]; then - find "$repo_root" -name "*.git" -type d 2>/dev/null | while read -r repo; do + # Use temp file to avoid subshell issue with piped while loop + local tmpfile="/tmp/gitea-repos.$$" + find "$repo_root" -name "*.git" -type d 2>/dev/null > "$tmpfile" + + while read -r repo; do + [ -z "$repo" ] && continue local rel_path="${repo#$repo_root/}" local name=$(basename "$repo" .git) local owner=$(dirname "$rel_path") @@ -383,7 +388,9 @@ list_repos() { json_add_string "size" "$size" [ -n "$mtime" ] && json_add_int "mtime" "$mtime" json_close_object - done + done < "$tmpfile" + + rm -f "$tmpfile" fi json_close_array @@ -528,7 +535,7 @@ list_backups() { local backup_dir="$data_path/backups" if [ -d "$backup_dir" ]; then - ls -1 "$backup_dir"/*.tar.gz 2>/dev/null | while read -r backup; do + for backup in "$backup_dir"/*.tar.gz; do [ -f "$backup" ] || continue local name=$(basename "$backup") local size=$(ls -lh "$backup" 2>/dev/null | awk '{print $5}')