mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 14:16:43 +00:00
fix(sync): prevent duplicate backup folders on Windows
On Windows, symlinks often fail so copyFallback() copies directories instead.
Previously, subsequent `ccs sync` runs would see the copied folder, fail the
isOurSymlink() check, and create a new .backup-{date} folder every time.
This fix adds Windows copy detection in installItem() before calling backupItem().
When a valid CCS copy is detected, it refreshes the content instead of backing up.
Fixes #409
This commit is contained in:
@@ -154,7 +154,23 @@ export class ClaudeSymlinkManager {
|
||||
return true; // Already correct, counts as success
|
||||
}
|
||||
|
||||
// Backup existing file/directory
|
||||
// On Windows, check if it's a valid copy (symlink fallback from previous sync)
|
||||
// This prevents creating duplicate backups on every sync
|
||||
if (process.platform === 'win32' && this.isCopiedItem(targetPath, sourcePath, item.type)) {
|
||||
// Remove existing copy and refresh with latest source content
|
||||
try {
|
||||
if (item.type === 'directory') {
|
||||
fs.rmSync(targetPath, { recursive: true, force: true });
|
||||
} else {
|
||||
fs.unlinkSync(targetPath);
|
||||
}
|
||||
} catch {
|
||||
// If removal fails, proceed to copy which will overwrite
|
||||
}
|
||||
return this.copyFallback(sourcePath, targetPath, item, silent);
|
||||
}
|
||||
|
||||
// Backup existing file/directory (only for non-CCS items)
|
||||
this.backupItem(targetPath, silent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user