From 53ed4370342e804cfd2b960ebf2f0bfa41992cbf Mon Sep 17 00:00:00 2001 From: Eyejoker Date: Mon, 30 Mar 2026 00:36:36 +0900 Subject: [PATCH] fix: handle directory-to-non-directory conflict in copySnapshotPaths When git ls-files returns directory entries (nested git repos), cpSync fails trying to overwrite a file placeholder with a directory. Now removes the conflicting target file before copying. --- src/paired-workspace-manager.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/paired-workspace-manager.ts b/src/paired-workspace-manager.ts index 4930e1b..5d79743 100644 --- a/src/paired-workspace-manager.ts +++ b/src/paired-workspace-manager.ts @@ -218,6 +218,14 @@ function copySnapshotPaths( if (!fs.existsSync(sourcePath)) continue; const targetPath = path.join(targetDir, relativePath); + const srcStat = fs.statSync(sourcePath); + // When source is a directory (e.g. nested git repo listed by git ls-files), + // remove any conflicting non-directory at the target before copying. + if (srcStat.isDirectory()) { + if (fs.existsSync(targetPath) && !fs.statSync(targetPath).isDirectory()) { + fs.rmSync(targetPath, { force: true }); + } + } fs.mkdirSync(path.dirname(targetPath), { recursive: true }); fs.cpSync(sourcePath, targetPath, { force: true, recursive: true }); }