intellibrix v1.0.0
    Preparing search index...

    Function writeFileAtomic

    • Replaces file with content so readers see the old content or the new, never a partial file: the content goes to a temporary file in the same directory, which then takes the file's place with a single rename. An existing file keeps its permissions. A crash or error leaves the original intact and removes the temporary file.

      With expected set, the file is re-read immediately before the swap and the write is refused if another writer got there first. For expected: null the swap is exact (link fails if the file exists). For existing files the check narrows the race to the instant between the re-read and the rename but does not close it against another process; use withFileLock to serialize writers within this one.

      Parameters

      Returns Promise<void>