Fix ciphertext buffer preallocation precedence; clippy fixes
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+5
-7
@@ -214,11 +214,10 @@ impl Store {
|
|||||||
}
|
}
|
||||||
let sp = dir.join(&shard.0);
|
let sp = dir.join(&shard.0);
|
||||||
for (name, _) in sorted_dir(&sp)? {
|
for (name, _) in sorted_dir(&sp)? {
|
||||||
if let Some(id) = name.to_str().and_then(Id::parse) {
|
if let Some(id) = name.to_str().and_then(Id::parse)
|
||||||
if id.shard() == shard.0.to_string_lossy() {
|
&& id.shard() == shard.0.to_string_lossy() {
|
||||||
ids.push(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut cat = Catalogue::default();
|
let mut cat = Catalogue::default();
|
||||||
@@ -337,12 +336,11 @@ impl Store {
|
|||||||
let mut first_err: Option<Error> = None;
|
let mut first_err: Option<Error> = None;
|
||||||
let mut remaining = size;
|
let mut remaining = size;
|
||||||
for i in 0..object_count(size) {
|
for i in 0..object_count(size) {
|
||||||
if pending.len() == OBJECT_BUFFERS {
|
if pending.len() == OBJECT_BUFFERS
|
||||||
if let Err(e) = pending.pop_front().expect("non-empty").wait().map_err(Error::new).and_then(|r| r) {
|
&& let Err(e) = pending.pop_front().expect("non-empty").wait().map_err(Error::new).and_then(|r| r) {
|
||||||
first_err = Some(e);
|
first_err = Some(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let id = seed.object_id(i);
|
let id = seed.object_id(i);
|
||||||
let part = remaining.min(CHUNK_DATA) as usize;
|
let part = remaining.min(CHUNK_DATA) as usize;
|
||||||
remaining -= part as u64;
|
remaining -= part as u64;
|
||||||
@@ -558,7 +556,7 @@ impl Inner {
|
|||||||
let dst = self.path(dir, id);
|
let dst = self.path(dir, id);
|
||||||
let shard = dst.parent().expect("sharded path").to_path_buf();
|
let shard = dst.parent().expect("sharded path").to_path_buf();
|
||||||
let (mut f, tmp) = pfs::create_temp(&shard, ".pending-").map_err(|e| Error::io("open", &shard, &e))?;
|
let (mut f, tmp) = pfs::create_temp(&shard, ".pending-").map_err(|e| Error::io("open", &shard, &e))?;
|
||||||
let mut ct = Vec::with_capacity(plaintext.len() + 32 << 10);
|
let mut ct = Vec::with_capacity(plaintext.len() + (32 << 10));
|
||||||
fury::encrypt_to(&mut ct, &self.recipient, plaintext, &mut self.entropy.rng(&id.0));
|
fury::encrypt_to(&mut ct, &self.recipient, plaintext, &mut self.entropy.rng(&id.0));
|
||||||
let r = (|| -> Result<()> {
|
let r = (|| -> Result<()> {
|
||||||
f.write_all(&ct).map_err(|e| Error::io("write", &tmp, &e))?;
|
f.write_all(&ct).map_err(|e| Error::io("write", &tmp, &e))?;
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ pub fn hex(b: &[u8]) -> String {
|
|||||||
|
|
||||||
pub fn parse_hex(s: &str) -> Option<Vec<u8>> {
|
pub fn parse_hex(s: &str) -> Option<Vec<u8>> {
|
||||||
let b = s.as_bytes();
|
let b = s.as_bytes();
|
||||||
if b.len() % 2 != 0 {
|
if !b.len().is_multiple_of(2) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let v = |c: u8| match c {
|
let v = |c: u8| match c {
|
||||||
|
|||||||
Reference in New Issue
Block a user