From 1b0dc9f680f4791f51f8f23ec3b68de774d72f21 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 31 Dec 2018 10:11:28 +0100 Subject: [PATCH] src/catar/encoder.rs: correctly sort goodbye items by hash key --- src/catar/encoder.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/catar/encoder.rs b/src/catar/encoder.rs index c7d3d559..4cf21837 100644 --- a/src/catar/encoder.rs +++ b/src/catar/encoder.rs @@ -122,7 +122,9 @@ impl CaTarEncoder { Ok(()) } - fn write_goodbye_table(&mut self, goodbye_offset: usize, goodbye_items: &[CaFormatGoodbyeItem]) -> Result<(), Error> { + fn write_goodbye_table(&mut self, goodbye_offset: usize, goodbye_items: &mut [CaFormatGoodbyeItem]) -> Result<(), Error> { + + goodbye_items.sort_unstable_by(|a, b| a.hash.cmp(&b.hash)); let item_count = goodbye_items.len(); @@ -278,7 +280,7 @@ impl CaTarEncoder { let goodbye_offset = self.writer_pos - dir_start_pos; - self.write_goodbye_table(goodbye_offset, &goodbye_items)?; + self.write_goodbye_table(goodbye_offset, &mut goodbye_items)?; println!("encode_dir: {:?} end1 {}", self.current_path, self.writer_pos); Ok(())