Skip to main content

StoreDir

Struct StoreDir 

Source
pub struct StoreDir { /* private fields */ }
Expand description

One store’s directory, owning the paths to its database, app-provided files, cache, settings and sibling locks. It never exposes the directory as a raw path.

Implementations§

Source§

impl StoreDir

Source

pub fn is_unpublished(&self) -> Result<bool, FileError>

Whether the store is still an unpublished installation: its marker is there (§13.4).

Source

pub fn id(&self) -> StoreId

The store identified by this directory.

Source

pub fn area_path(&self, area: FileArea) -> PathBuf

The folder of the store’s file area, for a test that looks at the files coven keeps there.

Source

pub fn files_exist(&self) -> bool

Whether any of the store’s files are on disk: its directory, or the directory under its deletion name that a deletion not yet finished leaves, for a test of what a deletion removes.

Source

pub fn copy_files(&self, to: &Path)

Copy the closed store’s directory into to, making to and every folder below it, as a backup of the app’s folder does. Panics on failure. Close the store first: a copy of an open store’s files is a copy of a crash.

Source

pub fn damage_settings(&self)

Make the store’s settings file unreadable, as a disk that wrote half of it leaves it: listing the store then reports its settings as unreadable. Panics on failure.

Source

pub fn damage_storage_settings(&self)

Make the store’s storage settings file unreadable, as damage_settings does the store’s settings. Panics on failure.

Source

pub fn restore_files(&self, from: &Path)

Replace the closed store’s directory with the copy at from, as restoring a backup does: the files the store has now are removed first. Panics on failure.

Trait Implementations§

Source§

impl Clone for StoreDir

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StoreDir

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StoreDirAccess for StoreDir

Source§

fn database_path(&self) -> PathBuf

The database file’s exact path for coven-database to open with SQLite. Callers never append path components to it.
Source§

fn input_database_path(&self) -> PathBuf

Retained remote input has its own SQLite owner: receiving bytes must not wait for a transaction applying those bytes to the application database.
Source§

fn audience_database_path(&self) -> PathBuf

The database a breaking migration’s per-audience check runs in, which lives only for that check (§18.3).
Source§

fn remove_audience_database(&self) -> Result<(), FileError>

Remove that database’s file and the files SQLite keeps beside it; one that is absent is already removed.
Source§

async fn rebuild_directory(&self) -> Result<StoreDir, SettingsError>

The store a rebuild runs in (§18.3): a store of its own in the folder rebuild of this store’s folder, with this store’s id and this device’s, the file areas empty and the class this layout gives the store’s files. A leftover from a crash goes first, once an instance of it in this process has finished closing. The caller removes it with Self::remove_rebuild_directory.
Source§

fn remove_rebuild_directory(&self) -> Result<(), FileError>

Remove the folder rebuild whole, with its locks; absent is removed.
Source§

fn retire_rebuild_directory(&self) -> Result<bool, FileError>

Move the folder rebuild aside, in one rename, so it leaves the store’s directory before coven deletes its files, after deleting what an earlier removal left there. Returns whether there was one to move.
Source§

fn return_rebuild_directory(&self) -> Result<(), FileError>

Move the folder retire_rebuild_directory moved aside back.
Source§

fn remove_retired_rebuild(&self) -> Result<(), FileError>

Delete the folder retire_rebuild_directory moved aside, whole. When that folder is absent, the call does nothing and succeeds. The database has no row for the files in that folder. Blocks while it deletes the folder.
Source§

fn unfinished_replacement( &self, ) -> Result<Option<ReplacementRecord>, SettingsError>

The record of a replacement whose swap is under way (§19.3). A record that remains only because publication was interrupted after removing the bootstrap marker, with settings already naming the new device, is not returned; the next replacement removes it. Reads only.
Source§

fn unfinished_deletion(&self) -> Result<Option<IfUnsent>, FileError>

What the store’s unfinished deletion does with unsent work, when this device recorded that it is deleting the store and leaving it (E1). Reads only.
Source§

fn record_deletion(&self, unsent: IfUnsent) -> Result<(), FileError>

Record that this device is deleting the store and leaving it, with what the deletion does with unsent work, before it journals the device’s removal. The record goes with the directory.
Source§

fn forget_deletion(&self) -> Result<(), FileError>

Remove the record of a deletion that ended before it journaled the device’s removal. An absent record succeeds.
Source§

fn discarded_devices(&self) -> Result<Vec<String>, FileError>

The name of each archive that a reset kept in the store’s directory, in order (§19.3).
Source§

fn discarded_device_size(&self, name: &str) -> Result<u64, FileError>

The size of everything in the archive name. Blocks while it walks the archive.
Source§

fn retire_discarded_device(&self, name: &str) -> Result<bool, FileError>

Move the archive name out of the store’s directory, in one rename, into the folder where coven deletes retired archives. Returns whether it was there to move.
Source§

fn return_discarded_device(&self, name: &str) -> Result<(), FileError>

Move the archive name back, as retire_discarded_device found it.
Source§

fn remove_retired_devices(&self) -> Result<(), FileError>

Delete the folder that retire_discarded_device moved archives into, then sync the store’s directory. The database has no row for the archives in that folder, so a removal that stops partway leaves the rest for the next call. Blocks while it removes them.
Source§

fn settings(&self) -> Result<StoreSettings, SettingsError>

The settings written when this store was created, restored or joined. Reading takes no lock; a read-only open uses it alongside a writer.
Source§

fn bugs(&self) -> &BugSinkRef

Where a bug in the store’s work that nobody waits for goes (E15): the app’s own reporter, which its directories were given.
Source§

async fn lock_for_open(&self) -> Result<StoreLock, StoreLockError>

Take the writer lock, awaiting release by a closing instance in this process. A live instance or another process still refuses immediately.
Source§

async fn lock_closed(&self) -> Result<ClosedStoreLock, StoreLockError>

Take the writer lock to read a closed store without opening it: a live instance or another process refuses immediately, and an instance closing in this process is waited for. Registered as closing, so an open in this process waits for its release (api.md E1).
Source§

fn lock_read_only(&self) -> Result<StoreReadLock, StoreLockError>

Prevent deletion while reading, alongside other readers and the writer. The guard must outlive every open file and database connection it protects.
Source§

fn lock_cache_write(&self) -> Result<CacheWriteLock, FileError>

Hold while a cache range recorded as being written gets its bytes with no database writer held. Shared by such writes in every process; exclude_cache_writes waits for all of them (Appendix C.3).
Source§

fn exclude_cache_writes(&self) -> Result<CacheWriteLock, FileError>

Wait until no cache range is being written in any process and keep new writes waiting, so a range still recorded as being written has no live writer (Appendix C.3).
Source§

fn lock_for_deletion(&self) -> Result<Option<StoreDeletionLock>, StoreLockError>

Lock an existing store or a directory left by an interrupted deletion, holding its writer, reader and bootstrap locks so that removal takes every lock file named for the store. An absent store with leftover locks can finish their removal on retry. A running restore, join or replacement refuses with StoreLockError::AlreadyOpen. A store whose replacement is unfinished is locked for deletion; an unfinished first installation is refused with StoreLockError::BootstrapPending. No directory is created by this call.
Source§

async fn closed(&self) -> Result<(), FileError>

Wait until no instance of this store in this process is closing, as lock_for_open does, so a deletion that follows is not refused by an instance only finishing its close, a replacement’s loading installation in its hidden directory included. A live instance is not waited for.
Source§

fn owned_file(&self, file: StoreFile) -> AtomicFile

Give a crate the capability for its reserved file, without exposing the store path or letting it name any other top-level file.
Source§

fn file(&self, area: FileArea, name: &FileName) -> AtomicFile

The capability for one app-provided copy or cache entry. All path construction stays here; the name cannot traverse directories.
Source§

fn create_writer( &self, area: FileArea, name: &FileName, ) -> Result<FileWriter, WriterError>

Create a named file in area for asynchronous streaming without replacing anything. The writer holds the store’s read lock until its handle and any cancelled I/O finish, so the store can’t be deleted under it. The caller records the name first and removes partial bytes after a failure.
Source§

fn writer_folder(&self, area: FileArea) -> Result<WriterFolder, WriterError>

Hold area’s folder for a run of files made in it: the store’s read lock is taken and the folder resolved once, for every writer WriterFolder::create makes, each as create_writer’s does.
Source§

fn resume_writer( &self, area: FileArea, name: &FileName, length: u64, ) -> Result<FileWriter, WriterError>

Reopen a named file of area that an earlier writer left unfinished, for appending after its first length bytes, which the caller recorded as synced; anything past them is cut off. A file with fewer bytes is refused. The writer holds the store’s read lock as create_writer’s does.
Source§

fn staged_file(&self, name: &StagedName) -> AtomicFile

The capability for one staged copy, in its staging’s folder.
Source§

fn staging_folder( &self, folder: &FileName, batch: &mut FlushBatch, ) -> Result<WriterFolder, StagingFolderError>

Make folder among the app-provided files for one staging’s copies, refusing one already there, and hold it as writer_folder holds an area’s folder. The app-provided files’ folder now holds the new folder, so batch‘s flush syncs it too (Appendix C.3). The caller records the copies’ names first, which name the folder.
Source§

fn remove_staged(&self, name: &StagedName) -> Result<(), FileError>

Remove a staged copy, then its staging’s folder once nothing is in it, syncing the folder that held each (Appendix C.3). An absent copy or folder is gone.
Source§

impl StoreLockProbe for StoreDir

Available on crate features test-utils only.
Source§

fn lock_exclusive(&self) -> Result<StoreLock, StoreLockError>

Take the writer lock, refusing at once when it is held.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more