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

Method open_readonly_mode

atomic-repository/src/repository/mod.rs:860–918  ·  view source on GitHub ↗
(
        path: &Path,
        operation_inspection: bool,
        no_migration: bool,
    )

Source from the content-addressed store, hash-verified

858 }
859
860 fn open_readonly_mode(
861 path: &Path,
862 operation_inspection: bool,
863 no_migration: bool,
864 ) -> Result<Self, RepositoryError> {
865 if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path) {
866 if no_migration {
867 return Err(RepositoryError::InvalidOperation {
868 message: "non-migrating sandbox inspection is unavailable".to_string(),
869 });
870 }
871 return Self::open_sandbox_readonly(working_root, canonical, &view);
872 }
873 let layout = working_copy::discover_layout(path)?;
874 let root = layout.working_root.clone();
875 let dot_dir = layout.common_dot_dir.clone();
876
877 // Open the pristine database in read-only mode. Identity validation below
878 // performs no repair and reports a typed migration-required error.
879 let database = if no_migration {
880 database::require_current_database(&dot_dir)?
881 } else {
882 ensure_database(&dot_dir)?
883 };
884 let pristine = if no_migration {
885 Pristine::open_readonly_without_recovery(database)
886 } else {
887 Pristine::open_readonly(database)
888 };
889 let pristine = Arc::new(pristine.map_err(RepositoryError::from)?);
890 let (working_copy_id, current_view) =
891 working_copy::load_registered_identity(&pristine, &layout)?;
892
893 // Open the change store without creating missing paths.
894 let change_store =
895 ChangeStore::open_existing(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY)
896 .map_err(|e| RepositoryError::Database(e.to_string()))?;
897
898 let repository = Self {
899 root,
900 dot_dir,
901 current_view,
902 pristine,
903 change_store,
904 is_sandbox: false,
905 semantic_closure_memo: Default::default(),
906 };
907 if !operation_inspection
908 && (repository.has_pending_deferred_tree_alignment()
909 || repository.working_copy_operation_requires_recovery(working_copy_id)?
910 || repository.repository_operation_requires_recovery()?)
911 {
912 return Err(RepositoryError::InvalidOperation {
913 message: "repository operation is still completing; retry with a writable repository open"
914 .to_string(),
915 });
916 }
917 Ok(repository)

Callers

nothing calls this directly

Calls 9

detect_sandboxFunction · 0.85
discover_layoutFunction · 0.85
require_current_databaseFunction · 0.85
ensure_databaseFunction · 0.85
load_registered_identityFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected