mod blob;
mod layout;
mod multipart;
#[cfg(test)]
mod tests;
pub use blob::{FsBlobStore, FsPackSink};
pub use layout::{FsLayoutStore, META_MARKER};
pub use multipart::FsPartSink;
use std::io::{self, ErrorKind};
use mkit_transport_file::RefFileError;
use crate::store::StoreError;
fn unavailable(e: impl std::error::Error + Send + Sync + 'static) -> StoreError {
StoreError::unavailable(e)
}
fn io_error(e: io::Error) -> StoreError {
match e.kind() {
ErrorKind::StorageFull | ErrorKind::QuotaExceeded => StoreError::Full,
ErrorKind::IsADirectory | ErrorKind::NotADirectory => {
StoreError::Invalid(format!("directory/file clash: {e}").into())
}
_ => StoreError::unavailable(e),
}
}
fn ref_file_error(e: RefFileError) -> StoreError {
match e {
RefFileError::InvalidName(name) => {
StoreError::Invalid(format!("ref name {name} is invalid or clashes with a ref").into())
}
RefFileError::Corrupt(name) => {
StoreError::Corrupt(format!("ref file {name} does not hold a ref id").into())
}
RefFileError::Io(e) => io_error(e),
other => unavailable(other),
}
}