diff --git a/wnfs-hamt/src/strategies/changes.rs b/wnfs-hamt/src/strategies/changes.rs index ea4a3eea..0a0550d8 100644 --- a/wnfs-hamt/src/strategies/changes.rs +++ b/wnfs-hamt/src/strategies/changes.rs @@ -31,7 +31,7 @@ pub(crate) fn generate_changes( pairs .clone() .into_iter() - .zip(randoms.into_iter()) + .zip(randoms) .filter(|(_, (num, _))| *num != 0) .map(|((k, _), (num, val))| match num { 1 => Change::Add(k, val), diff --git a/wnfs/src/private/file.rs b/wnfs/src/private/file.rs index 0f963bb5..66bc2c02 100644 --- a/wnfs/src/private/file.rs +++ b/wnfs/src/private/file.rs @@ -618,13 +618,14 @@ impl PrivateFile { } => { let mut cids = >::new(); let bare_name = &self.header.bare_name; + for label in Self::generate_shard_labels(key, 0, *block_count, bare_name) { let label_hash = &Sha3_256::hash(&label.as_bytes()); let block_cids = forest .get_encrypted(label_hash, store) .await? .ok_or(FsError::FileShardNotFound)?; - cids.extend(block_cids) + cids.extend(block_cids); } Ok(cids) } @@ -643,9 +644,9 @@ impl PrivateFile { if index >= block_count { return None; } - let label = Self::create_block_label(key, index, bare_name); index += 1; + Some(label) }) } @@ -653,13 +654,12 @@ impl PrivateFile { /// Creates the label for a block of a file. fn create_block_label(key: &SnapshotKey, index: usize, bare_name: &Namefilter) -> Namefilter { let key_bytes = key.0.as_bytes(); - let key_hash = Sha3_256::hash(&[key_bytes, &index.to_le_bytes()[..]].concat()); + let key_hash = Sha3_256::hash(&[key_bytes, &(index as u64).to_le_bytes()[..]].concat()); let mut label = bare_name.clone(); label.add(&key_bytes); label.add(&key_hash); label.saturate(); - label }