Skip to content

Commit 613bede

Browse files
beriberikixclaude
andcommitted
fix: handle file overwrite in completion installation
Fix completion installation failing when completion files already exist. The installCompletionFile method now properly removes existing files after backup creation, allowing copyItem to succeed. Fixes issue where `usbipd completion install` would fail with: - "usbipd" couldn't be copied because an item with the same name already exists - "_usbipd" couldn't be copied because an item with the same name already exists - "usbipd.fish" couldn't be copied because an item with the same name already exists 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0d8cea1 commit 613bede

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/USBIPDCore/CLI/CompletionInstaller.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ public class CompletionInstaller {
419419
/// - targetPath: Target installation path
420420
/// - Throws: Installation errors
421421
private func installCompletionFile(from sourcePath: String, to targetPath: String) throws {
422+
// Remove existing file if it exists (backup was already created in the calling method)
423+
if FileManager.default.fileExists(atPath: targetPath) {
424+
try FileManager.default.removeItem(atPath: targetPath)
425+
}
426+
422427
try FileManager.default.copyItem(atPath: sourcePath, toPath: targetPath)
423428

424429
// Set appropriate permissions

0 commit comments

Comments
 (0)