Skip to content

Commit d2b31f9

Browse files
committed
fix: Prevent unlink from continuing after processing a file
The previous implementation of the unlink command would continue processing files even after encountering an error or skipping a file due to it not being a symlink. This commit modifies the loop to return after processing each file, ensuring that the command stops processing the remaining files in such cases.
1 parent 89102b7 commit d2b31f9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/unlink.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ var unlinkCmd = &cobra.Command{
5252
fmt.Printf("Skipping %s\n", destPath)
5353
continue
5454
}
55+
os.Remove(destPath)
56+
internal.LogVerbose(verbose, "Removed %s symlink", destPath)
5557
}
56-
os.Remove(destPath)
57-
internal.LogVerbose(verbose, "Removed %s symlink", destPath)
58+
return nil
5859
}
5960
if dryRun {
6061
fmt.Printf("Would restore backup %s -> %s\n", backupPath, destPath)
@@ -68,9 +69,11 @@ var unlinkCmd = &cobra.Command{
6869
} else {
6970
fmt.Printf("󰩹 Removed symlink %s (no backup found)\n", destPath)
7071
}
72+
return nil
7173
}
7274
} else {
7375
fmt.Printf(" %s is not a symlink, skipping\n", destPath)
76+
return nil
7477
}
7578
}
7679
return nil

0 commit comments

Comments
 (0)