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
impl StoreDir
Sourcepub fn is_unpublished(&self) -> Result<bool, FileError>
pub fn is_unpublished(&self) -> Result<bool, FileError>
Whether the store is still an unpublished installation: its marker is there (§13.4).
Sourcepub fn area_path(&self, area: FileArea) -> PathBuf
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.
Sourcepub fn files_exist(&self) -> bool
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.
Sourcepub fn copy_files(&self, to: &Path)
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.
Sourcepub fn damage_settings(&self)
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.
Sourcepub fn damage_storage_settings(&self)
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.
Sourcepub fn restore_files(&self, from: &Path)
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 StoreDirAccess for StoreDir
impl StoreDirAccess for StoreDir
Source§fn database_path(&self) -> PathBuf
fn database_path(&self) -> PathBuf
Source§fn input_database_path(&self) -> PathBuf
fn input_database_path(&self) -> PathBuf
Source§fn audience_database_path(&self) -> PathBuf
fn audience_database_path(&self) -> PathBuf
Source§fn remove_audience_database(&self) -> Result<(), FileError>
fn remove_audience_database(&self) -> Result<(), FileError>
Source§async fn rebuild_directory(&self) -> Result<StoreDir, SettingsError>
async fn rebuild_directory(&self) -> Result<StoreDir, SettingsError>
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>
fn remove_rebuild_directory(&self) -> Result<(), FileError>
rebuild whole, with its locks; absent is removed.Source§fn retire_rebuild_directory(&self) -> Result<bool, FileError>
fn retire_rebuild_directory(&self) -> Result<bool, FileError>
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>
fn return_rebuild_directory(&self) -> Result<(), FileError>
retire_rebuild_directory moved aside back.Source§fn remove_retired_rebuild(&self) -> Result<(), FileError>
fn remove_retired_rebuild(&self) -> Result<(), FileError>
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>
fn unfinished_replacement( &self, ) -> Result<Option<ReplacementRecord>, SettingsError>
Source§fn unfinished_deletion(&self) -> Result<Option<IfUnsent>, FileError>
fn unfinished_deletion(&self) -> Result<Option<IfUnsent>, FileError>
Source§fn record_deletion(&self, unsent: IfUnsent) -> Result<(), FileError>
fn record_deletion(&self, unsent: IfUnsent) -> Result<(), FileError>
Source§fn forget_deletion(&self) -> Result<(), FileError>
fn forget_deletion(&self) -> Result<(), FileError>
Source§fn discarded_devices(&self) -> Result<Vec<String>, FileError>
fn discarded_devices(&self) -> Result<Vec<String>, FileError>
Source§fn discarded_device_size(&self, name: &str) -> Result<u64, FileError>
fn discarded_device_size(&self, name: &str) -> Result<u64, FileError>
name. Blocks while it walks
the archive.Source§fn retire_discarded_device(&self, name: &str) -> Result<bool, FileError>
fn retire_discarded_device(&self, name: &str) -> Result<bool, FileError>
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>
fn return_discarded_device(&self, name: &str) -> Result<(), FileError>
name back, as retire_discarded_device found it.Source§fn remove_retired_devices(&self) -> Result<(), FileError>
fn remove_retired_devices(&self) -> Result<(), FileError>
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>
fn settings(&self) -> Result<StoreSettings, SettingsError>
Source§fn bugs(&self) -> &BugSinkRef
fn bugs(&self) -> &BugSinkRef
Source§async fn lock_for_open(&self) -> Result<StoreLock, StoreLockError>
async fn lock_for_open(&self) -> Result<StoreLock, StoreLockError>
Source§async fn lock_closed(&self) -> Result<ClosedStoreLock, StoreLockError>
async fn lock_closed(&self) -> Result<ClosedStoreLock, StoreLockError>
Source§fn lock_read_only(&self) -> Result<StoreReadLock, StoreLockError>
fn lock_read_only(&self) -> Result<StoreReadLock, StoreLockError>
Source§fn lock_cache_write(&self) -> Result<CacheWriteLock, FileError>
fn lock_cache_write(&self) -> Result<CacheWriteLock, FileError>
exclude_cache_writes waits for all of them (Appendix C.3).Source§fn exclude_cache_writes(&self) -> Result<CacheWriteLock, FileError>
fn exclude_cache_writes(&self) -> Result<CacheWriteLock, FileError>
Source§fn lock_for_deletion(&self) -> Result<Option<StoreDeletionLock>, StoreLockError>
fn lock_for_deletion(&self) -> Result<Option<StoreDeletionLock>, StoreLockError>
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>
async fn closed(&self) -> Result<(), FileError>
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
fn owned_file(&self, file: StoreFile) -> AtomicFile
Source§fn file(&self, area: FileArea, name: &FileName) -> AtomicFile
fn file(&self, area: FileArea, name: &FileName) -> AtomicFile
Source§fn create_writer(
&self,
area: FileArea,
name: &FileName,
) -> Result<FileWriter, WriterError>
fn create_writer( &self, area: FileArea, name: &FileName, ) -> Result<FileWriter, WriterError>
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>
fn writer_folder(&self, area: FileArea) -> Result<WriterFolder, WriterError>
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>
fn resume_writer( &self, area: FileArea, name: &FileName, length: u64, ) -> Result<FileWriter, WriterError>
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
fn staged_file(&self, name: &StagedName) -> AtomicFile
Source§fn staging_folder(
&self,
folder: &FileName,
batch: &mut FlushBatch,
) -> Result<WriterFolder, StagingFolderError>
fn staging_folder( &self, folder: &FileName, batch: &mut FlushBatch, ) -> Result<WriterFolder, StagingFolderError>
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>
fn remove_staged(&self, name: &StagedName) -> Result<(), FileError>
Source§impl StoreLockProbe for StoreDir
Available on crate features test-utils only.
impl StoreLockProbe for StoreDir
test-utils only.