Procházet zdrojové kódy

fix(compose): use printf for path assembly to avoid shq-in-quotes bug

symlink_source used shq() for the cache path, which wraps it in single quotes. When embedded inside a double-quoted string assignment (snap="{cache}/hub/..."), the single quotes become literal characters in the path, breaking directory lookup. The same pattern would affect any cache path containing no special chars — the single-quote wrapping itself was the bug.

Fixed by assembling paths via printf (passing shq'd values as separate arguments), matching the existing resolve_path_ref_on_node pattern. Verified on dgx1.lan: the composed dir now builds correctly with symlinks resolving to the right repos (MXFP4 base + Lloyd NF4 expert overlay).
Alexander Korolev před 2 měsíci
rodič
revize
360f50446a
1 změnil soubory, kde provedl 8 přidání a 4 odebrání
  1. 8 4
      src/docker/compose.rs

+ 8 - 4
src/docker/compose.rs

@@ -120,18 +120,22 @@ async fn symlink_source(
     // inside the container where the HF cache is mounted at that exact path.
     // `ln -snf`: -s symlink, -n no-deref (treat existing symlink as a file,
     // don't dive into the dir it points to), -f force (overwrite earlier).
+    //
+    // Paths are assembled via `printf` (not embedded in double-quoted
+    // assignments) so shq's single-quote wrapping doesn't become literal
+    // characters in the path — same pattern as resolve_path_ref_on_node.
     let cmd = format!(
         "ref=\"$(cat {refs_q} 2>/dev/null)\" && test -n \"$ref\" && \
-         snap=\"{cache}/hub/{model}/snapshots/$ref\" && \
+         snap=\"$(printf '%s/hub/%s/snapshots/%s' {cache_q} {model_q} \"$ref\")\" && \
          test -d \"$snap\" && \
-         csnap=\"/root/.cache/huggingface/hub/{model}/snapshots/$ref\" && \
+         csnap=\"$(printf '/root/.cache/huggingface/hub/%s/snapshots/%s' {model_q} \"$ref\")\" && \
          for f in \"$snap\"/{glob}; do \
            [ -e \"$f\" ] || [ -L \"$f\" ] || continue; \
            ln -snf \"$csnap/$(basename \"$f\")\" {host_q}/; \
          done",
         refs_q = shq(&refs_path),
-        cache = shq(cache_str),
-        model = shq(&model_dir),
+        cache_q = shq(cache_str),
+        model_q = shq(&model_dir),
         host_q = shq(host_path),
     );