Commit 5911c2d
refactor: Simplify listObjectsSlurp by removing early returns and flattening control flow
This addresses review complexity concerns by refactoring the directory sealing
logic to use consistent state tracking and eliminate early returns.
Problems Addressed:
1. Early returns at lines 379, 432, 446 made lock state difficult to track
2. Nested conditionals created multiple complex execution paths
3. Inconsistent handling of already-sealed vs seal-failed scenarios
4. Difficult to verify lock invariants across all paths
Changes Made:
**All Four Sealing Paths Refactored:**
1. lock=true, inode != parent (lines 357-387):
- Removed early return on seal validation failure
- Use sealSucceeded flag to track result
- Single decision point: mark gap if sealed AND parent unchanged
- Clear lock flow: unlock → seal → relock → decide → unlock
2. lock=true, inode == parent (lines 388-410):
- Removed nested if/else for listDone vs already-sealed
- Use sealSucceeded flag
- Only mark gap if we successfully sealed (not if already done)
- Consistent with partial progress return on stale data
3. lock=false, inode != parent (lines 414-440):
- Removed early return on seal validation failure
- Use sealSucceeded and alreadySealed flags
- Mark gap if sealed OR already done (caller manages consistency)
- No parent lock changes (lock=false guarantee preserved)
4. lock=false, inode == parent (lines 441-466):
- Removed early return on seal validation failure
- Use sealSucceeded and alreadySealed flags
- Same logic as path 3 for consistency
**Improvements:**
✓ No early returns - all paths flow to natural end
✓ Consistent sealSucceeded flag pattern across all paths
✓ Single gap-marking decision point per path
✓ Clear lock state at all points (easier to verify correctness)
✓ Explicit handling of three states: sealed, already-done, failed
✓ Preserves all deadlock fixes (lock=false never unlocks parent)
✓ Preserves all race condition fixes (generations captured under locks)
✓ Preserves all validation logic (check listDone, verify +1)
The refactored code maintains identical functionality while being
significantly easier to review, reason about, and maintain.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent fbf7823 commit 5911c2d
1 file changed
+51
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
| 362 | + | |
363 | 363 | | |
364 | | - | |
365 | | - | |
| 364 | + | |
366 | 365 | | |
367 | 366 | | |
368 | 367 | | |
369 | 368 | | |
370 | 369 | | |
371 | 370 | | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 371 | + | |
380 | 372 | | |
| 373 | + | |
381 | 374 | | |
382 | 375 | | |
383 | 376 | | |
384 | | - | |
| 377 | + | |
385 | 378 | | |
386 | | - | |
| 379 | + | |
387 | 380 | | |
388 | 381 | | |
389 | 382 | | |
390 | 383 | | |
391 | | - | |
| 384 | + | |
392 | 385 | | |
393 | 386 | | |
394 | 387 | | |
395 | 388 | | |
396 | 389 | | |
397 | | - | |
| 390 | + | |
398 | 391 | | |
399 | 392 | | |
400 | 393 | | |
401 | 394 | | |
402 | 395 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
| 396 | + | |
409 | 397 | | |
410 | | - | |
411 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
412 | 403 | | |
413 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
414 | 408 | | |
415 | 409 | | |
416 | 410 | | |
| |||
419 | 413 | | |
420 | 414 | | |
421 | 415 | | |
422 | | - | |
| 416 | + | |
| 417 | + | |
423 | 418 | | |
424 | 419 | | |
425 | 420 | | |
426 | 421 | | |
427 | 422 | | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
| 423 | + | |
| 424 | + | |
433 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
434 | 429 | | |
435 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
436 | 441 | | |
437 | 442 | | |
438 | | - | |
| 443 | + | |
| 444 | + | |
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
442 | 448 | | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
| 449 | + | |
| 450 | + | |
447 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
448 | 465 | | |
449 | 466 | | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | 467 | | |
455 | 468 | | |
456 | 469 | | |
| |||
0 commit comments