| … | … | @@ -281,9 +281,15 @@ module.exports = class HyperSync extends ReadyResource { |
| 281 | 281 | result.synced.push(name); |
| 282 | 282 | this.emit('pull', remoteName, name, 'complete'); |
| 283 | 283 | } else { |
| 284 | | // Last resort — wipe + fresh clone. Catches repos where the |
| 285 | | // on-disk state is wedged in a way --refetch can't fix either. |
| 286 | | if (this._isStuck(repoPath, packDir) || !wasStuck) { |
| 284 | // Last resort — wipe + fresh clone ONLY when the repo is |
| 285 | // genuinely stuck (tmp_packs + no refs) AND we haven't |
| 286 | // already tried the pre-loop force-reclone (wasStuck). Do |
| 287 | // NOT wipe on generic fetch failure — that can mean network |
| 288 | // hiccup, peer unreachable, remote down, etc., and wiping |
| 289 | // would destroy a perfectly-good repo. Previous logic |
| 290 | // (`|| !wasStuck`) was backwards and nuked healthy repos on |
| 291 | // any transient fetch error. |
| 292 | if (!wasStuck && this._isStuck(repoPath, packDir)) { |
| 287 | 293 | fs.rmSync(repoPath, { recursive: true, force: true }); |
| 288 | 294 | try { |
| 289 | 295 | await this._exec('git', ['init', '--bare', repoPath]); |