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

Method has_recorded_content

atomic-repository/src/repository/content.rs:678–719  ·  view source on GitHub ↗

Check if a tracked file has any recorded content. This is a lightweight check that doesn't retrieve the actual content, useful for quickly determining if a file has been recorded. # Arguments `path` - Path to the file (relative to repository root) # Returns `true` if the file is tracked and has recorded content, `false` otherwise.

(&self, path: P)

Source from the content-addressed store, hash-verified

676 ///
677 /// `true` if the file is tracked and has recorded content, `false` otherwise.
678 pub fn has_recorded_content<P: AsRef<Path>>(&self, path: P) -> Result<bool, RepositoryError> {
679 use atomic_core::record::workflow::retrieve::has_content;
680
681 let path = path.as_ref();
682 let normalized = normalize_path(path);
683
684 let txn = self
685 .pristine
686 .read_txn()
687 .map_err(|e| RepositoryError::Database(e.to_string()))?;
688
689 let view = txn
690 .get_view(&self.current_view)
691 .map_err(|e| RepositoryError::Database(e.to_string()))?
692 .ok_or_else(|| RepositoryError::ViewNotFound {
693 name: self.current_view.clone(),
694 })?;
695 let visibility = graph_visibility_closure(&txn, &view)?;
696 let projection = self.project_tree_for_visibility(&txn, &visibility)?;
697 if projection.name_conflicts.contains_key(&normalized) {
698 return Err(RepositoryError::InvalidOperation {
699 message: format!(
700 "path '{}' has an unresolved name conflict; refusing to choose content",
701 normalized
702 ),
703 });
704 }
705 let Some(item) = projection.present.get(&normalized) else {
706 return Ok(false);
707 };
708 if item.is_directory {
709 return Ok(false);
710 }
711
712 let cached_txn =
713 CachedGraphTxn::new(&txn).map_err(|e| RepositoryError::Database(e.to_string()))?;
714 let view_graph = ViewGraph::new(&cached_txn, visibility);
715 let has = has_content(&view_graph, &self.change_store, item.position)
716 .map_err(|e| RepositoryError::Database(e.to_string()))?;
717
718 Ok(has)
719 }
720
721 // State-Based Content Retrieval
722

Callers

nothing calls this directly

Calls 10

graph_visibility_closureFunction · 0.85
has_contentFunction · 0.85
as_refMethod · 0.80
read_txnMethod · 0.80
contains_keyMethod · 0.80
getMethod · 0.65
normalize_pathFunction · 0.50
get_viewMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected