1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Multi-file writes, one file at a time.
//!
//! Two primitives, used by the user-scope skill installer and by the
//! repository landing. A lock serializes writers over one target. A stage
//! writes every intended byte beside its destination and replaces it by
//! rename.
//!
//! What this guarantees, and what it does not. Each replacement is atomic
//! on its own; the set is not. A run the process does not finish leaves
//! whole files and the record the previous run wrote, and running it again
//! finishes the rest. Recovery after power loss rests on the persistence
//! order below and on the platform's `fsync` semantics, and is claimed no
//! further.
//!
//! The persistence order is fixed and the same for every domain. Each
//! scratch file is written and synced, then renamed over its destination,
//! then the destination's directory synced. The record is replaced last.
use Utf8Path;
/// Flush a directory entry, so a rename into it survives a crash.
///
/// A platform that refuses to sync a directory reports `InvalidInput`, and
/// there the ordering rests on the platform's own semantics rather than on
/// a call this tool can make.
///
/// # Errors
///
/// Any I/O error other than a refusal to sync a directory at all.
/// Flush the directory holding `path`, where it has one.
///
/// # Errors
///
/// Any I/O error other than a refusal to sync a directory at all.