Skip to main content

sync_dir

Function sync_dir 

Source
pub fn sync_dir(dir: &Path) -> Result<()>
Expand description

Flushes dir’s own metadata, making renames into it durable.

Call after the rename that installs a staged file: the directory entry it created needs a separate flush to reach disk. Skipping this keeps the atomicity guarantee and loses only durability, to a power cut.

§Platforms

Unix only. A no-op on Windows: as durable as NTFS makes it.

§Errors

  • std::io::Error if dir could not be opened or flushed. EINVAL is tolerated as “no such step”; never errors on Windows.