Skip to content

Commit ee8ebf4

Browse files
mikolalysenkoclaudemikolalysenko
authored
Write every utils::fs atomic file through one stage-and-rename core (#728) (#858)
* Start refactor for #728 Assisted-by: Claude Code:claude-opus-5-5 * Share one stage-and-rename core in utils::fs Every atomic file write (lockfiles, manifests, vendored artifacts, group-commit replays) now goes through one blocking core that owns the stage name, the stage's creation mode, the fsync, the set-mode-then-rename order and the unlink on failure. The async writers run it on the blocking pool, and the blob cache builds its .socket-dl- stage name through the same helper. A hardening fix to the write path now lands once instead of twice. No behavior change: the same bytes, modes, fsyncs and stage names. Refs #728 Assisted-by: Claude Code:claude-opus-5-5 --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: mikolalysenko <mik@socket.dev>
1 parent abd3c45 commit ee8ebf4

2 files changed

Lines changed: 256 additions & 180 deletions

File tree

‎crates/socket-patch-core/src/api/blob_fetcher.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,6 @@ async fn stream_cache_entry_atomic(
424424
"cache entry path has no parent directory",
425425
))
426426
})?;
427-
let stem = dest
428-
.file_name()
429-
.map(|n| n.to_string_lossy().into_owned())
430-
.unwrap_or_else(|| "blob".to_string());
431427
// The cache directory (`.socket/blobs/`, `.socket/diffs/`) is created
432428
// here, by the first download, and nowhere earlier. A fetch that lands
433429
// nothing (all 404, offline, every hash mismatched, every body cut
@@ -442,9 +438,7 @@ async fn stream_cache_entry_atomic(
442438
}
443439
created_dirs.push(dir);
444440
}
445-
// Leading dot keeps the stage out of editor/glob views; the uuid suffix
446-
// keeps concurrent writers of the same entry from colliding.
447-
let stage = parent.join(format!(".socket-dl-{}-{}", stem, uuid::Uuid::new_v4()));
441+
let stage = crate::utils::fs::stage_path(dest, ".socket-dl-");
448442

449443
let result = async {
450444
// Inside the cleanup scope: a `create_dir_all` that makes some

0 commit comments

Comments
 (0)