Unified · Split
| @@ -23,6 +23,9 @@ quick_error! { · 22 unmodified lines | ||
| 23 | 23 | RefDelta { |
| 24 | 24 | display("Ref delta objects are not supported as there is no way to look them up. Resolve them beforehand.") |
| 25 | 25 | } |
| 26 | + IteratorInvariantTrailer { | |
| 27 | + display("The iterator failed to set a trailing hash over all prior pack entries in the last provided entry") | |
| 28 | + } | |
| 26 | 29 | } |
| 27 | 30 | } |
| 28 | 31 | |
| @@ -60,6 +63,7 @@ impl pack::index::File { · 31 unmodified lines | ||
| 60 | 63 | let mut num_objects = 0; |
| 61 | 64 | // This array starts our sorted by pack-offset |
| 62 | 65 | let mut index_entries = Vec::with_capacity(entries.size_hint().0); |
| 66 | + let mut last_seen_trailer = None; | |
| 63 | 67 | for entry in entries { |
| 64 | 68 | let pack::data::iter::Entry { |
| 65 | 69 | header, |
| @@ -67,7 +71,7 @@ impl pack::index::File { · 1 unmodified line | ||
| 67 | 71 | header_size: _, |
| 68 | 72 | compressed: _, |
| 69 | 73 | decompressed, |
| 70 | − trailer: _, | |
| 74 | + trailer, | |
| 71 | 75 | } = entry?; |
| 72 | 76 | use pack::data::Header::*; |
| 73 | 77 | num_objects += 1; |
| @@ -93,20 +97,24 @@ impl pack::index::File { · 19 unmodified lines | ||
| 93 | 97 | _pack_offset: pack_offset, |
| 94 | 98 | _crc32: 0, // TBD |
| 95 | 99 | _base_bytes: decompressed, |
| 96 | − }) | |
| 100 | + }); | |
| 101 | + last_seen_trailer = trailer; | |
| 97 | 102 | } |
| 98 | 103 | |
| 99 | 104 | out.write_all(V2_SIGNATURE)?; |
| 100 | 105 | |
| 106 | + // Write header | |
| 101 | 107 | let mut buf = [0u8; 4]; |
| 102 | 108 | BigEndian::write_u32(&mut buf, kind as u32); |
| 103 | 109 | out.write_all(&buf)?; |
| 104 | 110 | |
| 111 | + // todo: write fanout | |
| 112 | + | |
| 105 | 113 | let _index_hash = out.hash.digest(); |
| 106 | 114 | Ok(Outcome { |
| 107 | 115 | index_kind: kind, |
| 108 | 116 | index_hash: owned::Id::from([0u8; 20]), |
| 109 | − pack_hash: owned::Id::from([0u8; 20]), | |
| 117 | + pack_hash: last_seen_trailer.ok_or(Error::IteratorInvariantTrailer)?, | |
| 110 | 118 | num_objects, |
| 111 | 119 | }) |
| 112 | 120 | } |