diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 39785fc..d8cd56b 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -199,7 +199,7 @@ impl FromStr for Operation { | |||
| 199 | 199 | ||
| 200 | let path = path_str.parse().map_err(|_| err())?; | 200 | let path = path_str.parse().map_err(|_| err())?; |
| 201 | 201 | ||
| 202 | OperationData::CreateDir(OperationCreateDir { path }) | 202 | OperationData::MkDir(OperationMkDir { path }) |
| 203 | } | 203 | } |
| 204 | OPERATION_KIND_RENAME => { | 204 | OPERATION_KIND_RENAME => { |
| 205 | let old_str = iter.next().ok_or_else(err)?; | 205 | let old_str = iter.next().ok_or_else(err)?; |
| @@ -244,7 +244,7 @@ impl Display for Operation { | |||
| 244 | "{}\t{}\t{}\t{}", | 244 | "{}\t{}\t{}\t{}", |
| 245 | OPERATION_KIND_CREATE_FILE, data.path, data.blob, data.size | 245 | OPERATION_KIND_CREATE_FILE, data.path, data.blob, data.size |
| 246 | ), | 246 | ), |
| 247 | OperationData::CreateDir(data) => { | 247 | OperationData::MkDir(data) => { |
| 248 | write!(f, "{}\t{}", OPERATION_KIND_CREATE_DIR, data.path) | 248 | write!(f, "{}\t{}", OPERATION_KIND_CREATE_DIR, data.path) |
| 249 | } | 249 | } |
| 250 | OperationData::Remove(data) => write!(f, "{}\t{}", OPERATION_KIND_REMOVE, data.path), | 250 | OperationData::Remove(data) => write!(f, "{}\t{}", OPERATION_KIND_REMOVE, data.path), |
| @@ -265,7 +265,7 @@ pub struct OperationHeader { | |||
| 265 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 265 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
| 266 | pub enum OperationData { | 266 | pub enum OperationData { |
| 267 | CreateFile(OperationCreateFile), | 267 | CreateFile(OperationCreateFile), |
| 268 | CreateDir(OperationCreateDir), | 268 | MkDir(OperationMkDir), |
| 269 | Remove(OperationRemove), | 269 | Remove(OperationRemove), |
| 270 | Rename(OperationRename), | 270 | Rename(OperationRename), |
| 271 | } | 271 | } |
| @@ -278,7 +278,7 @@ pub struct OperationCreateFile { | |||
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 280 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
| 281 | pub struct OperationCreateDir { | 281 | pub struct OperationMkDir { |
| 282 | pub path: DrivePath, | 282 | pub path: DrivePath, |
| 283 | } | 283 | } |
| 284 | 284 | ||
| @@ -511,7 +511,7 @@ impl Default for Fs { | |||
| 511 | pub fn apply(fs: &mut Fs, op: &Operation) -> Result<(), FsError> { | 511 | pub fn apply(fs: &mut Fs, op: &Operation) -> Result<(), FsError> { |
| 512 | match &op.data { | 512 | match &op.data { |
| 513 | OperationData::CreateFile(data) => apply_create_file(fs, &op.header, &data), | 513 | OperationData::CreateFile(data) => apply_create_file(fs, &op.header, &data), |
| 514 | OperationData::CreateDir(data) => apply_create_dir(fs, &op.header, &data), | 514 | OperationData::MkDir(data) => apply_create_dir(fs, &op.header, &data), |
| 515 | OperationData::Remove(data) => apply_remove(fs, &op.header, &data), | 515 | OperationData::Remove(data) => apply_remove(fs, &op.header, &data), |
| 516 | OperationData::Rename(data) => apply_rename(fs, &op.header, &data), | 516 | OperationData::Rename(data) => apply_rename(fs, &op.header, &data), |
| 517 | } | 517 | } |
| @@ -586,7 +586,7 @@ pub fn apply_create_file( | |||
| 586 | pub fn apply_create_dir( | 586 | pub fn apply_create_dir( |
| 587 | fs: &mut Fs, | 587 | fs: &mut Fs, |
| 588 | header: &OperationHeader, | 588 | header: &OperationHeader, |
| 589 | data: &OperationCreateDir, | 589 | data: &OperationMkDir, |
| 590 | ) -> Result<(), FsError> { | 590 | ) -> Result<(), FsError> { |
| 591 | let (parent, name) = data | 591 | let (parent, name) = data |
| 592 | .path | 592 | .path |
| @@ -718,7 +718,7 @@ struct CliCommon { | |||
| 718 | #[derive(Debug, Subcommand)] | 718 | #[derive(Debug, Subcommand)] |
| 719 | enum Cmd { | 719 | enum Cmd { |
| 720 | CreateFile(CreateFileArgs), | 720 | CreateFile(CreateFileArgs), |
| 721 | CreateDir(CreateDirArgs), | 721 | Mkdir(MkDirArgs), |
| 722 | Remove(RemoveArgs), | 722 | Remove(RemoveArgs), |
| 723 | Rename(RenameArgs), | 723 | Rename(RenameArgs), |
| 724 | Ls(LsArgs), | 724 | Ls(LsArgs), |
| @@ -745,7 +745,7 @@ struct CreateFileArgs { | |||
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | #[derive(Debug, Args)] | 747 | #[derive(Debug, Args)] |
| 748 | struct CreateDirArgs { | 748 | struct MkDirArgs { |
| 749 | #[clap(flatten)] | 749 | #[clap(flatten)] |
| 750 | common: CliCommon, | 750 | common: CliCommon, |
| 751 | 751 | ||
| @@ -838,7 +838,7 @@ fn main() { | |||
| 838 | 838 | ||
| 839 | match cli.cmd { | 839 | match cli.cmd { |
| 840 | Cmd::CreateFile(args) => cmd_create_file(args), | 840 | Cmd::CreateFile(args) => cmd_create_file(args), |
| 841 | Cmd::CreateDir(args) => cmd_create_dir(args), | 841 | Cmd::Mkdir(args) => cmd_mkdir(args), |
| 842 | Cmd::Remove(args) => cmd_remove(args), | 842 | Cmd::Remove(args) => cmd_remove(args), |
| 843 | Cmd::Rename(args) => cmd_rename(args), | 843 | Cmd::Rename(args) => cmd_rename(args), |
| 844 | Cmd::Ls(args) => cmd_ls(args), | 844 | Cmd::Ls(args) => cmd_ls(args), |
| @@ -878,7 +878,7 @@ fn cmd_create_file(args: CreateFileArgs) { | |||
| 878 | common_write_log_file(&args.common, &ops); | 878 | common_write_log_file(&args.common, &ops); |
| 879 | } | 879 | } |
| 880 | 880 | ||
| 881 | fn cmd_create_dir(args: CreateDirArgs) { | 881 | fn cmd_mkdir(args: MkDirArgs) { |
| 882 | let _lock = common_write_lock(&args.common); | 882 | let _lock = common_write_lock(&args.common); |
| 883 | let mut fs = Fs::default(); | 883 | let mut fs = Fs::default(); |
| 884 | let mut ops = common_read_log_file(&args.common); | 884 | let mut ops = common_read_log_file(&args.common); |
| @@ -893,7 +893,7 @@ fn cmd_create_dir(args: CreateDirArgs) { | |||
| 893 | revision, | 893 | revision, |
| 894 | email: args.email, | 894 | email: args.email, |
| 895 | }, | 895 | }, |
| 896 | data: OperationData::CreateDir(OperationCreateDir { path: args.path }), | 896 | data: OperationData::MkDir(OperationMkDir { path: args.path }), |
| 897 | }; | 897 | }; |
| 898 | apply(&mut fs, &new_op).unwrap(); | 898 | apply(&mut fs, &new_op).unwrap(); |
| 899 | ops.push(new_op); | 899 | ops.push(new_op); |
