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

Function refuse_unknown_tables

atomic-core/src/pristine/merge.rs:231–260  ·  view source on GitHub ↗

Unknown tables cannot be copied without their types. Dropping an empty one loses nothing, and retired tables are no longer read; any other table must stop the merge. Returns the non-empty retired tables left behind.

(
    txn: &ReadTransaction,
    known: &BTreeSet<String>,
    source: &Path,
)

Source from the content-addressed store, hash-verified

229/// loses nothing, and retired tables are no longer read; any other table must
230/// stop the merge. Returns the non-empty retired tables left behind.
231fn refuse_unknown_tables(
232 txn: &ReadTransaction,
233 known: &BTreeSet<String>,
234 source: &Path,
235) -> PristineResult<Vec<String>> {
236 let mut non_empty = Vec::new();
237 for handle in txn.list_tables()? {
238 let name = handle.name().to_string();
239 if !known.contains(name.as_str()) && txn.open_untyped_table(handle)?.len()? > 0 {
240 non_empty.push(name);
241 }
242 }
243 for handle in txn.list_multimap_tables()? {
244 let name = handle.name().to_string();
245 if !known.contains(name.as_str()) && txn.open_untyped_multimap_table(handle)?.len()? > 0 {
246 non_empty.push(name);
247 }
248 }
249 let (left_behind, unknown): (Vec<_>, Vec<_>) = non_empty
250 .into_iter()
251 .partition(|name| RETIRED_TABLES.contains(&name.as_str()));
252 if unknown.is_empty() {
253 return Ok(left_behind);
254 }
255 Err(merge_error(format!(
256 "{} holds tables this atomic does not know ({}); upgrade atomic before opening this repository",
257 source.display(),
258 unknown.join(", ")
259 )))
260}
261
262#[derive(Default)]
263struct DigestBuilder {

Callers 2

merge_intoMethod · 0.85
verify_unchangedMethod · 0.85

Calls 8

merge_errorFunction · 0.85
nameMethod · 0.45
containsMethod · 0.45
as_strMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
into_iterMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected