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

Method open

atomic-core/src/pristine/txn/pristine/snapshot.rs:21–38  ·  view source on GitHub ↗
(path: &Path, create: bool)

Source from the content-addressed store, hash-verified

19
20impl SnapshotBackend {
21 pub(super) fn open(path: &Path, create: bool) -> Result<Self, DatabaseError> {
22 let file = OpenOptions::new()
23 .read(true)
24 .write(true)
25 .create(create)
26 .truncate(false)
27 .open(path)?;
28 // create_with_backend also initializes empty files. Existing-only
29 // opens must retain their refusal to initialize an empty database.
30 if !create && file.metadata()?.len() == 0 {
31 return Err(io::Error::new(
32 io::ErrorKind::InvalidData,
33 "existing pristine database is empty",
34 )
35 .into());
36 }
37 Ok(Self(Arc::new(FileBackend::new(file)?)))
38 }
39}
40
41impl StorageBackend for SnapshotBackend {

Callers 1

copy_snapshotMethod · 0.45

Calls 6

truncateMethod · 0.80
createMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
lenMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected