clippy: remove unnecessary clones

and from::<T>(T)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler
2021-01-15 14:38:27 +01:00
parent 47ea98e0e3
commit 4428818412
35 changed files with 47 additions and 51 deletions

View File

@ -18,7 +18,7 @@ impl <W: Write> ChecksumWriter<W> {
let hasher = crc32fast::Hasher::new();
let signer = match config {
Some(config) => {
let tied_signer = Tied::new(config.clone(), |config| {
let tied_signer = Tied::new(config, |config| {
Box::new(unsafe { (*config).data_signer() })
});
Some(tied_signer)

View File

@ -80,7 +80,7 @@ impl ChunkStore {
let default_options = CreateOptions::new();
match create_path(&base, Some(default_options.clone()), Some(options.clone())) {
match create_path(&base, Some(default_options), Some(options.clone())) {
Err(err) => bail!("unable to create chunk store '{}' at {:?} - {}", name, base, err),
Ok(res) => if ! res { nix::unistd::chown(&base, Some(uid), Some(gid))? },
}
@ -113,9 +113,8 @@ impl ChunkStore {
}
fn lockfile_path<P: Into<PathBuf>>(base: P) -> PathBuf {
let base: PathBuf = base.into();
let mut lockfile_path: PathBuf = base.into();
let mut lockfile_path = base.clone();
lockfile_path.push(".lock");
lockfile_path

View File

@ -334,9 +334,7 @@ impl DataStore {
auth_id: &Authid,
) -> Result<(Authid, DirLockGuard), Error> {
// create intermediate path first:
let base_path = self.base_path();
let mut full_path = base_path.clone();
let mut full_path = self.base_path();
full_path.push(backup_group.backup_type());
std::fs::create_dir_all(&full_path)?;

View File

@ -229,7 +229,7 @@ impl IndexFile for DynamicIndexReader {
Some(ChunkReadInfo {
range: start..end,
digest: self.index[pos].digest.clone(),
digest: self.index[pos].digest,
})
}

View File

@ -233,7 +233,7 @@ pub fn decrypt_key_config(
let mut result = [0u8; 32];
result.copy_from_slice(&key);
let crypt_config = CryptConfig::new(result.clone())?;
let crypt_config = CryptConfig::new(result)?;
let fingerprint = crypt_config.fingerprint();
if let Some(ref stored_fingerprint) = key_config.fingerprint {
if &fingerprint != stored_fingerprint {
@ -313,9 +313,9 @@ fn encrypt_decrypt_test() -> Result<(), Error> {
])),
};
let encrypted = rsa_encrypt_key_config(public.clone(), &key).expect("encryption failed");
let encrypted = rsa_encrypt_key_config(public, &key).expect("encryption failed");
let (decrypted, created, fingerprint) =
rsa_decrypt_key_config(private.clone(), &encrypted, &passphrase)
rsa_decrypt_key_config(private, &encrypted, &passphrase)
.expect("decryption failed");
assert_eq!(key.created, created);

View File

@ -186,7 +186,7 @@ impl BackupManifest {
manifest["unprotected"]["key-fingerprint"] = serde_json::to_value(fingerprint)?;
}
let manifest = serde_json::to_string_pretty(&manifest).unwrap().into();
let manifest = serde_json::to_string_pretty(&manifest).unwrap();
Ok(manifest)
}