Showing the changes to gitoxide-core/src (1 of 3 files). Show all
Unified · Split
| @@ -67,8 +67,13 @@ pub fn stream_len(mut s: impl io::Seek) -> io::Result<u64> { · 66 unmodified lines | |||
| 67 | 67 | ||
| 68 | pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 2..=3; | 68 | pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 2..=3; |
| 69 | 69 | ||
| 70 | pub enum PathOrRead { | ||
| 71 | Path(PathBuf), | ||
| 72 | Read(Box<dyn std::io::Read + Send + 'static>), | ||
| 73 | } | ||
| 74 | |||
| 70 | pub fn from_pack( | 75 | pub fn from_pack( |
| 71 | pack: Option<PathBuf>, | 76 | pack: PathOrRead, |
| 72 | directory: Option<PathBuf>, | 77 | directory: Option<PathBuf>, |
| 73 | progress: impl Progress, | 78 | progress: impl Progress, |
| 74 | ctx: Context<impl io::Write>, | 79 | ctx: Context<impl io::Write>, |
| @@ -82,15 +87,12 @@ pub fn from_pack( · 7 unmodified lines | |||
| 82 | let out = ctx.out; | 87 | let out = ctx.out; |
| 83 | let format = ctx.format; | 88 | let format = ctx.format; |
| 84 | let res = match pack { | 89 | let res = match pack { |
| 85 | Some(pack) => { | 90 | PathOrRead::Path(pack) => { |
| 86 | let pack_len = pack.metadata()?.len(); | 91 | let pack_len = pack.metadata()?.len(); |
| 87 | let pack_file = fs::File::open(pack)?; | 92 | let pack_file = fs::File::open(pack)?; |
| 88 | pack::Bundle::write_to_directory_eagerly(pack_file, Some(pack_len), directory, progress, options) | 93 | pack::Bundle::write_to_directory_eagerly(pack_file, Some(pack_len), directory, progress, options) |
| 89 | } | 94 | } |
| 90 | None => { | 95 | PathOrRead::Read(input) => pack::Bundle::write_to_directory_eagerly(input, None, directory, progress, options), |
| 91 | let stdin = io::stdin(); | ||
| 92 | pack::Bundle::write_to_directory_eagerly(stdin, None, directory, progress, options) | ||
| 93 | } | ||
| 94 | } | 96 | } |
| 95 | .with_context(|| "Failed to write pack and index")?; | 97 | .with_context(|| "Failed to write pack and index")?; |
| 96 | match format { | 98 | match format { |