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 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-01-24 14:27:58 +01:00
parent b17da12677
commit 549e189059
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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}')