diff options
| -rw-r--r-- | fctdrive/src/main.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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; | |||
| 19 | #[derive(Debug)] | 19 | #[derive(Debug)] |
| 20 | pub struct InvalidBlobId; | 20 | pub struct InvalidBlobId; |
| 21 | 21 | ||
| 22 | impl Display for InvalidBlobId { | ||
| 23 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| 24 | write!(f, "invalid blob id") | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | impl std::error::Error for InvalidBlobId {} | ||
| 29 | |||
| 22 | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)] | 30 | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)] |
| 23 | pub struct BlobId([u8; 32]); | 31 | pub struct BlobId([u8; 32]); |
| 24 | 32 | ||
| @@ -688,6 +696,7 @@ enum Cmd { | |||
| 688 | Rename(RenameArgs), | 696 | Rename(RenameArgs), |
| 689 | Ls(LsArgs), | 697 | Ls(LsArgs), |
| 690 | Import(ImportArgs), | 698 | Import(ImportArgs), |
| 699 | Blob(BlobArgs), | ||
| 691 | } | 700 | } |
| 692 | 701 | ||
| 693 | #[derive(Debug, Args)] | 702 | #[derive(Debug, Args)] |
| @@ -781,6 +790,14 @@ struct ImportArgs { | |||
| 781 | path: PathBuf, | 790 | path: PathBuf, |
| 782 | } | 791 | } |
| 783 | 792 | ||
| 793 | #[derive(Debug, Args)] | ||
| 794 | struct BlobArgs { | ||
| 795 | #[clap(flatten)] | ||
| 796 | common: CliCommon, | ||
| 797 | |||
| 798 | blob_id: BlobId, | ||
| 799 | } | ||
| 800 | |||
| 784 | fn main() { | 801 | fn main() { |
| 785 | let cli = Cli::parse(); | 802 | let cli = Cli::parse(); |
| 786 | 803 | ||
| @@ -791,6 +808,7 @@ fn main() { | |||
| 791 | Cmd::Rename(args) => cmd_rename(args), | 808 | Cmd::Rename(args) => cmd_rename(args), |
| 792 | Cmd::Ls(args) => cmd_ls(args), | 809 | Cmd::Ls(args) => cmd_ls(args), |
| 793 | Cmd::Import(args) => cmd_import(args), | 810 | Cmd::Import(args) => cmd_import(args), |
| 811 | Cmd::Blob(args) => cmd_blob(args), | ||
| 794 | } | 812 | } |
| 795 | } | 813 | } |
| 796 | 814 | ||
| @@ -1039,6 +1057,12 @@ fn cmd_import(args: ImportArgs) { | |||
| 1039 | common_write_log_file(&args.common, &ops); | 1057 | common_write_log_file(&args.common, &ops); |
| 1040 | } | 1058 | } |
| 1041 | 1059 | ||
| 1060 | fn cmd_blob(args: BlobArgs) { | ||
| 1061 | let store = common_create_blob_store(&args.common); | ||
| 1062 | let path = blob_path(&store, &args.blob_id); | ||
| 1063 | println!("{}", path.display()); | ||
| 1064 | } | ||
| 1065 | |||
| 1042 | fn collect_all_file_paths(root: &Path) -> Vec<PathBuf> { | 1066 | fn collect_all_file_paths(root: &Path) -> Vec<PathBuf> { |
| 1043 | let mut queue = vec![root.to_path_buf()]; | 1067 | let mut queue = vec![root.to_path_buf()]; |
| 1044 | let mut files = vec![]; | 1068 | let mut files = vec![]; |
