pub struct FsBlobStore { /* private fields */ }
Expand description
An abstraction over a blob storage in a file system directory.
Implementations§
Source§impl FsBlobStore
impl FsBlobStore
Sourcepub fn new(basedir: impl AsRef<Path>) -> Result<Self, Error>
pub fn new(basedir: impl AsRef<Path>) -> Result<Self, Error>
Create a new file system-backed blob storage engine.
The basedir
is where the blobs and temporary files will be stored. The
caller must ensure that either basedir
is absolute, or that the path
remains valid throughout the object’s lifetime.
If the basedir does not exist, it will automatically be created if the
mkbasedir
feature is enabled.
§Errors
If mkbasedir
feature is enabled, Error::IO
indicates that the base
directory can not be created.
Sourcepub fn with_minsize(
basedir: impl AsRef<Path>,
minsize: usize,
) -> Result<Self, Error>
pub fn with_minsize( basedir: impl AsRef<Path>, minsize: usize, ) -> Result<Self, Error>
This function serves the purpose as FsBlobStore::new()
, but will
enable support for storing small files in memory, rather than be written
to disk.
§Notes
If support for storing small files in memory is enabled, “files” that will fall into this category will not actually be stored in the file system, and thus will neither be enumerable or read.
The calling application must maintain its own databasse for such cases.
Sourcepub fn enumerate(&self) -> (Receiver<ContentHash, ()>, JoinHandle<()>)
Available on crate feature enumerate
only.
pub fn enumerate(&self) -> (Receiver<ContentHash, ()>, JoinHandle<()>)
enumerate
only.Get a list of all hashes in the fs blob store.
On success, returns an object that will stream the records in an unspecified order.
§Caveat
This method exists, despite it being incongruous with the overall
philosophy of the blob store. The application should maintain a
separate database of the blob hashes stored in the FsBlobStore
, and
enumerations of hashes should be performed in the database instead.
Enumerating the FsBlobStore
is potentially slow. Its use should be
limited to infrequent integrity checks.
This method will launch a background thread which lives as long as it performs its work. It is inadvisable to allow end users to trigger this method to be run.
Sourcepub fn get_fname(&self, hash: &[u8]) -> Result<PathBuf, Error>
Available on crate feature get-fname
only.
pub fn get_fname(&self, hash: &[u8]) -> Result<PathBuf, Error>
get-fname
only.Get complete filename of an existing blob.
Returns Ok(PathBuf)
containing the path to the content, if it exists.
§Caveat
The use of this method is strongly discouraged. Use
FsBlobStore::have()
to check if a blob exists in the datastore,
FsBlobStore::reader()
to read a blob, and FsBlobStore::rm()
to remove
a blob.
§Errors
std::io::Error
indicates the file doesn’t exists or its metadata could
not be read.