MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / process_single_file

Function process_single_file

atomic-repository/src/parallel_record/worker.rs:21–41  ·  view source on GitHub ↗

Process a single file on a rayon worker thread. This function is the per-file workhorse. It reads the file from disk, diffs against old content, tokenizes, and builds hunks. It is designed to be called from a rayon parallel iterator and must not access any shared mutable state.

(
    input: &FileRecordInput,
    options: &RecordingOptions,
)

Source from the content-addressed store, hash-verified

19/// to be called from a rayon parallel iterator and must not access any
20/// shared mutable state.
21pub fn process_single_file(
22 input: &FileRecordInput,
23 options: &RecordingOptions,
24) -> Result<FileRecordOutput, String> {
25 let file_start = Instant::now();
26
27 let result = match input.kind {
28 FileRecordKind::Added => process_added_file(input, options),
29 FileRecordKind::Modified => process_modified_file(input, options),
30 FileRecordKind::Deleted => process_deleted_file(input, options),
31 FileRecordKind::DirectoryAdded => process_directory_added(input),
32 FileRecordKind::DirectoryDeleted => process_directory_deleted(input),
33 };
34
35 // Attach timing to the result
36 let elapsed = file_start.elapsed().as_millis() as u64;
37 result.map(|mut output| {
38 output.stats.processing_time_ms = elapsed;
39 output
40 })
41}
42
43/// Process an added file: read content, detect encoding, create hunks, tokenize.
44fn process_added_file(

Callers 1

parallel_record_filesFunction · 0.85

Calls 5

process_added_fileFunction · 0.85
process_modified_fileFunction · 0.85
process_deleted_fileFunction · 0.85
process_directory_addedFunction · 0.85

Tested by

no test coverage detected