Repository navigation
Commit 668e5f4
fix(libretro): sync the save directory after the FDS rename
agy's review of #561 (the round after 5ddf520): the FDS save now fsyncs
its data before the rename, but a rename is a directory change, and
without syncing the directory the new entry may not survive a power loss.
The desktop's `write_atomic` already does this (`sync_parent_dir`), so the
libretro helper now matches it on Unix: open the parent, `sync_all`, and
treat EINVAL / ENOTSUP / EBADF as "this filesystem offers no directory
barrier" rather than a failure -- the same set, for the same reason (a
network mount must not fail every save on a path that fully succeeded).
Any other error is returned even though the file was replaced. Here that
only leaves the disk marked dirty, so the next flush writes it again; the
desktop documents the same trade-off at length in atomic_write.rs.
Not unit-tested, as with the data fsync: the failure it guards is a power
loss. libretro tests 38/38, clippy clean.
Answered on the PR without code: its BPS "integer overflow" is refuted at
patch.rs:400 (`length > target_size - out.len()`, a subtraction under the
invariant `out.len() <= target_size`); `rawset(mt, "__gc", f)` after
`setmetatable` is pinned as never honoured; the wasm heap is NF-09
(documented, piccolo 0.3.3 has no limit to set).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014qfTKi2M3swo7qnwvYCkDj1 parent 87fc6ef commit 668e5f4
2 files changed
Lines changed: 29 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1642 | 1642 | | |
1643 | 1643 | | |
1644 | 1644 | | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
1645 | 1653 | | |
1646 | 1654 | | |
1647 | 1655 | | |
| |||
1660 | 1668 | | |
1661 | 1669 | | |
1662 | 1670 | | |
1663 | | - | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
1664 | 1691 | | |
1665 | 1692 | | |
1666 | 1693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
0 commit comments