From 0d90737e06f3fc556e65bca56ec5defe8433be16 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Fri, 8 Aug 2025 19:54:26 +0100 Subject: added blob subcommand --- fctdrive/src/main.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/fctdrive/src/main.rs b/fctdrive/src/main.rs index 12955bd..3a8e5f9 100644 --- a/fctdrive/src/main.rs +++ b/fctdrive/src/main.rs @@ -19,6 +19,14 @@ const BLOB_STORE_HIERARCHY_DEPTH: usize = 4; #[derive(Debug)] pub struct InvalidBlobId; +impl Display for InvalidBlobId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "invalid blob id") + } +} + +impl std::error::Error for InvalidBlobId {} + #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)] pub struct BlobId([u8; 32]); @@ -688,6 +696,7 @@ enum Cmd { Rename(RenameArgs), Ls(LsArgs), Import(ImportArgs), + Blob(BlobArgs), } #[derive(Debug, Args)] @@ -781,6 +790,14 @@ struct ImportArgs { path: PathBuf, } +#[derive(Debug, Args)] +struct BlobArgs { + #[clap(flatten)] + common: CliCommon, + + blob_id: BlobId, +} + fn main() { let cli = Cli::parse(); @@ -791,6 +808,7 @@ fn main() { Cmd::Rename(args) => cmd_rename(args), Cmd::Ls(args) => cmd_ls(args), Cmd::Import(args) => cmd_import(args), + Cmd::Blob(args) => cmd_blob(args), } } @@ -1039,6 +1057,12 @@ fn cmd_import(args: ImportArgs) { common_write_log_file(&args.common, &ops); } +fn cmd_blob(args: BlobArgs) { + let store = common_create_blob_store(&args.common); + let path = blob_path(&store, &args.blob_id); + println!("{}", path.display()); +} + fn collect_all_file_paths(root: &Path) -> Vec { let mut queue = vec![root.to_path_buf()]; let mut files = vec![]; -- cgit