Function kismet_cache::raw_cache::insert_or_touch[][src]

pub fn insert_or_touch(
    from: impl AsRef<Path>,
    to: impl AsRef<Path>
) -> Result<()>
Expand description

Consumes the file from and publishes it to the raw cache file to, a file directly under the raw cache directly, only if that file does not already exist.

If the file exists, from is still consumed, but to is not updated; instead, its access bit is set to true.

On success, from is deleted. On failure, the cache directory is always in a valid state.

The link will be atomic, but the source file must be private to the caller: this function accesses the source file multiple times.

If durability is necessary, the caller is responsible for sync_dataing the contents of from. This function does not fsync the cache directory itself: it’s a cache, so stale contents are assumed safe.