Retrieve a complete file with options.
(
txn: &mut T,
path: &str,
options: &RetrievalOptions,
)
| 415 | |
| 416 | /// Retrieve a complete file with options. |
| 417 | pub 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. |
| 448 | pub fn file_exists<T: MutTxnT>(txn: &mut T, path: &str) -> PristineResult<bool> { |
no test coverage detected