refactor(tvix/castore/import): make module, split off fs and error
Move error types and filesystem-specific functions to a separate file, and keep the fs:: namespace in public exports. Change-Id: I5e9e83ad78d9aea38553fafc293d3e4f8c31a8c1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11486 Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com> Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
c4cb099823
commit
e9db0449e7
7 changed files with 225 additions and 197 deletions
39
tvix/castore/src/import/error.rs
Normal file
39
tvix/castore/src/import/error.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use std::{fs::FileType, path::PathBuf};
|
||||
|
||||
use crate::Error as CastoreError;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("failed to upload directory at {0}: {1}")]
|
||||
UploadDirectoryError(PathBuf, CastoreError),
|
||||
|
||||
#[error("invalid encoding encountered for entry {0:?}")]
|
||||
InvalidEncoding(PathBuf),
|
||||
|
||||
#[error("unable to stat {0}: {1}")]
|
||||
UnableToStat(PathBuf, std::io::Error),
|
||||
|
||||
#[error("unable to open {0}: {1}")]
|
||||
UnableToOpen(PathBuf, std::io::Error),
|
||||
|
||||
#[error("unable to read {0}: {1}")]
|
||||
UnableToRead(PathBuf, std::io::Error),
|
||||
|
||||
#[error("unsupported file {0} type: {1:?}")]
|
||||
UnsupportedFileType(PathBuf, FileType),
|
||||
}
|
||||
|
||||
impl From<CastoreError> for Error {
|
||||
fn from(value: CastoreError) -> Self {
|
||||
match value {
|
||||
CastoreError::InvalidRequest(_) => panic!("tvix bug"),
|
||||
CastoreError::StorageError(_) => panic!("error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for std::io::Error {
|
||||
fn from(value: Error) -> Self {
|
||||
std::io::Error::new(std::io::ErrorKind::Other, value)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue