← Commit history
Merge PR #634: tools/kicad-cli-remote: compress large boards for macOS and Linux desktops (a 20 MB poured board never arrived)
1 file changed
+25−1
tools/kicad-cli-remote+25−1@@ -107,7 +107,7 @@ cleanup_remote() { ab shell_execute "$(python3 -c 'import json,sys;print(json.dumps({"command":"rmdir /s /q \""+sys.argv[1].replace("/","\\")+"\"","reason":"clean up the kicad-cli temp folder"}))' "$1")" >/dev/null || true } # Send local files to one remote folder: <dest> <files...>-send_to() {+send_to_raw() { local d="$1"; shift local reply moves reply=$(ab send_files "$(python3 -c 'import json,sys;print(json.dumps({"filePaths":sys.argv[2:],"dest":sys.argv[1],"reason":"files for a kicad-cli job for adom-aiflow (native KiCad on the desktop)"}))' "$d" "$@")")@@ -124,6 +124,30 @@ for p in r.get("destinationPaths") or []: [[ -n "$moves" ]] || return 0 lx_script "mkdir -p $(printf '%q' "$d") && $(tr '\n' ';' <<<"$moves")" 120 "move the sent files into the kicad-cli job folder" >/dev/null }+# The relay times out on transfers above about 8 MB, and a board with filled pours can be 20 MB.+# Files over 3 MB travel gzip-compressed and are unpacked in the job folder; each transfer carries+# at most 4 MB (one larger file goes alone). macOS and Linux desktops only (gunzip in the job folder).+send_to() {+ if ! posix; then send_to_raw "$@"; return; fi # Windows desktops: unchanged+ local d="$1"; shift+ local batch=() bsize=0 f sz z unz=() ztmp+ ztmp=$(mktemp -d)+ for f in "$@"; do+ sz=$(stat -c %s "$f" 2>/dev/null || echo 0)+ if (( sz > 3000000 )); then+ z="$ztmp/$(basename "$f").gz"; gzip -c "$f" > "$z"; unz+=("$(basename "$f")"); f="$z"; sz=$(stat -c %s "$z")+ fi+ if (( ${#batch[@]} > 0 && bsize + sz > 4000000 )); then send_to_raw "$d" "${batch[@]}"; batch=(); bsize=0; fi+ batch+=("$f"); bsize=$((bsize + sz))+ done+ (( ${#batch[@]} > 0 )) && send_to_raw "$d" "${batch[@]}"+ if (( ${#unz[@]} > 0 )); then+ local cmd="cd $(printf '%q' "$d")"+ for f in "${unz[@]}"; do cmd+=" && gunzip -f -- $(printf '%q' "$f.gz")"; done+ lx_script "$cmd" 180 "unpack the compressed files in the kicad-cli job folder" >/dev/null+ fi+ rm -rf "$ztmp"+} # The project files a kicad-cli job needs, grouped by folder relative to the job folder, one # "<sub>\t<json list>" line per folder. Modes: # sch <root.kicad_sch> the hierarchy, its .kicad_pro, the lib tables and their libraries