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

Function get_file_with_options

atomic-core/src/output/crdt.rs:417–445  ·  view source on GitHub ↗

Retrieve a complete file with options.

(
    txn: &mut T,
    path: &str,
    options: &RetrievalOptions,
)

Source from the content-addressed store, hash-verified

415
416/// Retrieve a complete file with options.
417pub fn get_file_with_options<T: MutTxnT>(
418 txn: &mut T,
419 path: &str,
420 options: &RetrievalOptions,
421) -> PristineResult<Option<File>> {
422 // Look up trunk by path
423 let trunk_id = match txn.get_trunk_by_path(path)? {
424 Some(id) => id,
425 None => return Ok(None), // File not found
426 };
427
428 let trunk_key = encode_trunk_id(&trunk_id);
429
430 // Get trunk metadata
431 let trunk_data = match txn.get_crdt_trunk(&trunk_key)? {
432 Some(data) => data,
433 None => return Ok(None), // Trunk not found
434 };
435
436 let mut file = File::new(trunk_id, &trunk_data);
437
438 // Get all lines
439 let lines = get_file_lines_by_trunk(txn, trunk_id, options)?;
440 for line in lines {
441 file.add_line(line);
442 }
443
444 Ok(Some(file))
445}
446
447/// Check if a file exists in the CRDT tables.
448pub fn file_exists<T: MutTxnT>(txn: &mut T, path: &str) -> PristineResult<bool> {

Callers 1

get_fileFunction · 0.85

Calls 5

encode_trunk_idFunction · 0.85
get_file_lines_by_trunkFunction · 0.85
get_trunk_by_pathMethod · 0.45
get_crdt_trunkMethod · 0.45
add_lineMethod · 0.45

Tested by

no test coverage detected