mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-21 15:02:21 +02:00
Six writers repeated the same publication sequence: create a temporary file in the target directory, write it, sync_all, optionally run a cancellation check, then NamedTempFile::persist over the target. `core::fs::write_atomic` runs exactly that order and optionally fsyncs the directory afterwards (best effort, as extension storage did). Each site keeps its temporary-file prefix (`.spotiflac-` for extension storage, `.spotiflac-m3u-` for M3U export, tempfile's `.tmp` default, exposed as `DEFAULT_TEMP_PREFIX`, for the registry cache, lyrics cache and both network cover writers), its check placement between fsync and rename, and its error text: `WriteAtomicError` displays a persist failure with tempfile's own message, and converts to the underlying io::Error where the site previously used `PersistError::error`. Not converted, because their publication differs: playlist staging and collection snapshots use persist_noclobber (collections also skips fsync), the backup restore stages into a temporary directory, and the extension package download maps each step to its own error context. spotiflac-core now depends on the workspace `tempfile` already used by the other crates; the lockfile only gains that edge.