From ae399e2a0d747e2e344ad440d3be6a6c1c61af9c Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 26 Feb 2026 08:47:54 -0500 Subject: [PATCH] fix(torch): handle self-copy update paths and record bitvid context note --- memory-update.md | 16 ++++++++++++++++ torch/src/ops.mjs | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/memory-update.md b/memory-update.md index 85b85d5b..65766600 100644 --- a/memory-update.md +++ b/memory-update.md @@ -16,3 +16,19 @@ ## Operational note - In this repo, when `torch-lock update` is run with `--prefix torch`, path resolution can collide on `torch/src`. - If that occurs, running the updater from repo root is a reliable fallback. + +## Resolution Applied - 2026-02-26 +- Implemented same-path guards in `torch/src/ops.mjs`: + - `copyDir(src, dest)` now skips when `path.resolve(src) === path.resolve(dest)`. + - `copyFile(src, dest, ...)` now skips no-op self-copy operations for identical resolved paths. +- This aligns with upstream TORCH fix notes for self-hosted installs where package root equals install target. + +## Validation After Fix +- `npx --prefix torch --no-install torch-lock update --force` now succeeds (no `src and dest cannot be the same` error). +- Update created backup: `torch/_backups/backup_2026-02-26T13-45-30-661Z`. +- `npx --prefix torch --no-install torch-lock doctor` reports: `7 passed, 0 warned, 0 failed`. + +## Operator Context Note (Adam) +- `bitvid` is a different project Adam is working on. +- If a prompt context references `bitvid` instead of `SeedPass`, treat it as a likely working-directory mismatch. +- In that case, ask Adam to confirm whether the active directory/repo is correct before making changes. diff --git a/torch/src/ops.mjs b/torch/src/ops.mjs index 567e2a9b..ccf86d99 100644 --- a/torch/src/ops.mjs +++ b/torch/src/ops.mjs @@ -85,9 +85,15 @@ function getPaths(root, installDirName) { * @param {string} dest - Destination directory path. */ function copyDir(src, dest) { - if (fs.existsSync(src)) { - fs.cpSync(src, dest, { recursive: true }); + if (!fs.existsSync(src)) return false; + + // Guard self-hosted installs where source and target resolve to the same path. + if (path.resolve(src) === path.resolve(dest)) { + return false; } + + fs.cpSync(src, dest, { recursive: true }); + return true; } /** @@ -126,6 +132,10 @@ function transformContent(content, installDirName) { * @returns {boolean} - True if copied/overwritten, false if skipped or source missing. */ function copyFile(src, dest, transform = false, overwrite = true, installDirName = 'torch') { + if (path.resolve(src) === path.resolve(dest)) { + return false; // Skip no-op self-copy + } + if (fs.existsSync(dest) && !overwrite) { return false; // Skipped }