﻿# Make a renamed model manifest durable through its directory

Synchronize prepared manifest contents and the renamed directory entry before claiming durable local publication; atomic visibility is a separate boundary.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/guide-storage-fsync-directory/
Language: en

A publisher writes a new model manifest, renames it successfully and acknowledges completion. After a host crash, recovery does not find the intended published name. Runtime visibility and persistence are different boundaries. For a local filesystem, preserve the distinction between synchronizing the file's contents and synchronizing the containing directory entry before making a durable-publication claim.

## Define the acknowledged object

Identify the manifest, referenced immutable files and recovery expectation. If the manifest points to artifact data that was never made durable, preserving only the manifest cannot recover a usable revision. State whether acknowledgment means visible to current readers or expected to survive the modeled crash. These are separate contracts, and the publisher must not silently promise the stronger one.

## Finish the file before publication

Create a private staging file in the intended publication directory and write the complete validated manifest. Handle write and close errors under the actual API contract. Synchronize the file before publishing its name when durability is required. Merely closing the descriptor or seeing the new bytes through another reader does not establish that the storage persistence boundary has been reached.

## Publish within the local boundary

Use the applicable same-filesystem rename behavior for the prepared file. The rename can provide atomic replacement visibility for that name, but that is not the complete crash-durability protocol. Keep the staging and final names, directory identity and actual operation outcome in the publication record. Another filesystem or remote object API can require a different protocol entirely.

## Synchronize the directory entry

Linux fsync documentation explicitly distinguishes file synchronization from persistence of its containing directory entry. Synchronize an appropriate descriptor for the affected directory after the rename and check the outcome. This guide's simple case keeps staging and destination in the same directory. A more complex operation involving multiple directories needs its own persistence reasoning rather than assuming one directory sync covers every modified namespace entry.

## Verify recovery and failure reporting

Test interrupted publication in an isolated filesystem environment matching the supported storage stack. Preserve synchronization failures as failed or uncertain publication, rather than acknowledging success after the error. Device, filesystem and storage guarantees remain relevant. A useful result documents the intended recovery state and verified boundaries; it does not promise universal crash behavior for every filesystem, mount option or controller configuration merely because a syscall returned successfully once.

## Primary references

[Linux File and Directory Synchronization](https://man7.org/linux/man-pages/man2/fsync.2.html).

[Linux Atomic Rename and Filesystem Boundaries](https://man7.org/linux/man-pages/man2/rename.2.html).

[Linux Open File Descriptions and Directory Handles](https://man7.org/linux/man-pages/man2/open.2.html).

Related reading: [Init container downloads an artifact again: making preparation idempotent](/journal/kubernetes-init-artifact-download/); [Keep tokenizer vocabulary, special tokens and chat templates in one release](/journal/tokenizer-artifact-release-manifest/).
