Skip to content

Commit c7be9e9

Browse files
A6GibKmbilelmoussaoui
authored andcommitted
client: file: Do not waste computed key
Otherwise the key would have to be recomputed in the next derive_key call.
1 parent cf77469 commit c7be9e9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

client/src/file/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl Keyring {
160160
}
161161
};
162162

163-
if validate_items {
163+
let key = if validate_items {
164164
let key = keyring.derive_key(&secret)?;
165165

166166
let mut n_broken_items = 0;
@@ -190,14 +190,16 @@ impl Keyring {
190190
return Err(Error::IncorrectSecret);
191191
}
192192

193-
drop(key);
194-
}
193+
Some(Arc::new(key))
194+
} else {
195+
None
196+
};
195197

196198
Ok(Self {
197199
keyring: Arc::new(RwLock::new(keyring)),
198200
path: Some(path.as_ref().to_path_buf()),
199201
mtime: Mutex::new(mtime),
200-
key: Default::default(),
202+
key: Mutex::new(key),
201203
secret: Mutex::new(Arc::new(secret)),
202204
})
203205
}

0 commit comments

Comments
 (0)