Commit 25f2246
committed
Probe target existence before rename
Use fs.access as an explicit existence probe and distinguish an absent target from real I/O failures. The change introduces a targetExists flag and a try/catch around fs.access so that expected "not found" control flow proceeds to fs.rename, while genuine errors from fs.unlink (e.g. permission issues or locks) will propagate instead of being silently swallowed. A clarifying comment was also added to explain the reasoning.1 parent 00420c8 commit 25f2246
1 file changed
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
94 | 102 | | |
95 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
96 | 109 | | |
97 | 110 | | |
98 | 111 | | |
99 | 112 | | |
100 | | - | |
| 113 | + | |
101 | 114 | | |
102 | 115 | | |
103 | 116 | | |
| |||
0 commit comments