From e8764ef60dc5ad2c5984a7e6252bdc33956262e3 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 28 Jul 2025 12:58:24 +0200 Subject: [PATCH] fix cp issue --- misc/build.func | 2 +- misc/tools.func | 34 ++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/misc/build.func b/misc/build.func index 850cd27e..fa17adbb 100644 --- a/misc/build.func +++ b/misc/build.func @@ -1212,7 +1212,7 @@ EOF seen_devices["$dev_target"]=1 pci_addr=$(basename "$bypath" | cut -d- -f1 --complement | sed 's/-render//' || true) - pci_info=$(lspci -nn | grep "$pci_addr" || true) + pci_info=$(lspci -nn | grep "${pci_addr#0000:}" || true) name="${pci_info#*: }" [[ -z "$name" ]] && name="Unknown GPU ($pci_addr)" diff --git a/misc/tools.func b/misc/tools.func index f8811698..04688d40 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -1007,23 +1007,41 @@ function fetch_and_deploy_gh_release() { local top_dirs top_dirs=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1 -type d | wc -l) - - if [[ "$top_dirs" -eq 1 ]]; then + local top_entries inner_dir + top_entries=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1) + if [[ "$(echo "$top_entries" | wc -l)" -eq 1 && -d "$top_entries" ]]; then # Strip leading folder - local inner_dir - inner_dir=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1 -type d) + inner_dir="$top_entries" shopt -s dotglob nullglob - cp -r "$inner_dir"/* "$target/" + if compgen -G "$inner_dir/*" >/dev/null; then + cp -r "$inner_dir"/* "$target/" || { + msg_error "Failed to copy contents from $inner_dir to $target" + rm -rf "$tmpdir" "$unpack_tmp" + return 1 + } + else + msg_error "Inner directory is empty: $inner_dir" + rm -rf "$tmpdir" "$unpack_tmp" + return 1 + fi shopt -u dotglob nullglob else # Copy all contents shopt -s dotglob nullglob - cp -r "$unpack_tmp"/* "$target/" + if compgen -G "$unpack_tmp/*" >/dev/null; then + cp -r "$unpack_tmp"/* "$target/" || { + msg_error "Failed to copy contents to $target" + rm -rf "$tmpdir" "$unpack_tmp" + return 1 + } + else + msg_error "Unpacked archive is empty" + rm -rf "$tmpdir" "$unpack_tmp" + return 1 + fi shopt -u dotglob nullglob fi - rm -rf "$unpack_tmp" - ### Singlefile Mode ### elif [[ "$mode" == "singlefile" ]]; then local pattern="${6%\"}"