Skip to content

Commit

Permalink
fix dir hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
qti3e committed Aug 12, 2024
1 parent 1ad5de9 commit cded0f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/b3fs/src/directory/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl DirectoryHasher {
// file name.
if self.counter > 0 {
let end = 3 + self.last_filename_size;
let prev_name = &self.transcript_buffer[3..end];
let prev_name = &self.transcript_buffer[1..end];

if prev_name == entry.name {
return Err(Error::FilenameNotUnique);
Expand Down
14 changes: 7 additions & 7 deletions lib/b3fs/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ use crate::directory::hasher::DirectoryHasher;
use crate::directory::transcript::{hash_transcript, write_entry_transcript};

/// Returns the `i`-th ascii character starting from `A`.
///
/// `name(a) < name(b) for a < b`
pub fn name(mut i: usize) -> String {
const CHARS: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let mut bytes = Vec::new();
const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let mut bytes = vec![b'A'; 14];
let mut j = bytes.len();
while i > 0 {
bytes.push(CHARS.as_bytes()[i % CHARS.len()]);
j -= 1;
bytes[j] = CHARS[i % CHARS.len()];
i /= CHARS.len();
}
while bytes.len() < 5 {
bytes.push(CHARS.as_bytes()[0]);
}
bytes.reverse();
String::from_utf8(bytes).unwrap()
}

Expand Down

0 comments on commit cded0f3

Please sign in to comment.