mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-11 22:53:00 +00:00
refactor(workflow): compute snapshot stats inside the blocking task
write_snapshot_blocking now derives entry_count and bytes from the entries slice instead of taking them as parameters. The arity drops from five to three, and the cheap O(n) work moves off the async runtime into spawn_blocking where the rest of the snapshot already runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
964c31837e
commit
ab4d299fde
1 changed files with 3 additions and 5 deletions
|
|
@ -192,14 +192,12 @@ impl RunMetadataWriterHandle {
|
|||
let entries = dump
|
||||
.git_entries()
|
||||
.map_err(RunMetadataError::DumpSerialize)?;
|
||||
let entry_count = entries.len();
|
||||
let bytes = metadata_entries_bytes(&entries);
|
||||
let message = message.to_string();
|
||||
let writer = Arc::clone(&self.writer);
|
||||
|
||||
task::spawn_blocking(move || {
|
||||
let mut guard = writer.lock().expect("metadata writer mutex poisoned");
|
||||
guard.write_snapshot_blocking(&entries, entry_count, bytes, &message, token.as_deref())
|
||||
guard.write_snapshot_blocking(&entries, &message, token.as_deref())
|
||||
})
|
||||
.await
|
||||
.map_err(RunMetadataError::Join)?
|
||||
|
|
@ -305,12 +303,12 @@ impl RunMetadataWriter {
|
|||
fn write_snapshot_blocking(
|
||||
&mut self,
|
||||
entries: &[(String, Vec<u8>)],
|
||||
entry_count: usize,
|
||||
bytes: u64,
|
||||
message: &str,
|
||||
token: Option<&str>,
|
||||
) -> Result<MetadataSnapshot, RunMetadataError> {
|
||||
self.discover_parent(token)?;
|
||||
let entry_count = entries.len();
|
||||
let bytes = metadata_entries_bytes(entries);
|
||||
for (path, _) in entries {
|
||||
validate_metadata_path(path)?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue