5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-01-20 14:03:53 +03:00

remove needless borrows

Fixes the needless_borrow lint.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
Maximiliano Sandoval 2024-12-02 10:57:56 +01:00 committed by Fabian Grünbichler
parent 2fab9155b3
commit f36e8fea91
8 changed files with 12 additions and 14 deletions

View File

@ -529,7 +529,7 @@ impl Shell {
None => bail!("no such file or directory: {entry:?}"), None => bail!("no such file or directory: {entry:?}"),
} }
} else { } else {
let pxar_entry = parent_pxar_entry(&stack)?; let pxar_entry = parent_pxar_entry(stack)?;
let parent_dir = pxar_entry.enter_directory().await?; let parent_dir = pxar_entry.enter_directory().await?;
match parent_dir.lookup(entry).await? { match parent_dir.lookup(entry).await? {
Some(entry) => { Some(entry) => {
@ -575,7 +575,7 @@ impl Shell {
None => bail!("no such file or directory: {:?}", entry), None => bail!("no such file or directory: {:?}", entry),
} }
} else { } else {
let pxar_entry = parent_pxar_entry(&stack)?; let pxar_entry = parent_pxar_entry(stack)?;
let parent_dir = block_on(pxar_entry.enter_directory())?; let parent_dir = block_on(pxar_entry.enter_directory())?;
match block_on(parent_dir.lookup(entry))? { match block_on(parent_dir.lookup(entry))? {
Some(entry) => { Some(entry) => {
@ -766,7 +766,7 @@ impl Shell {
let mut out = std::io::stdout(); let mut out = std::io::stdout();
let items = crate::pxar::tools::pxar_metadata_read_dir(dir).await?; let items = crate::pxar::tools::pxar_metadata_read_dir(dir).await?;
for item in items { for item in items {
out.write_all(&item.file_name().as_bytes())?; out.write_all(item.file_name().as_bytes())?;
out.write_all(b"\n")?; out.write_all(b"\n")?;
} }
return Ok(()); return Ok(());

View File

@ -428,7 +428,7 @@ impl BackupDir {
std::fs::create_dir_all(&path)?; std::fs::create_dir_all(&path)?;
let ts = self.backup_time_string(); let ts = self.backup_time_string();
path.push(&format!("{ts}{MANIFEST_LOCK_NAME}")); path.push(format!("{ts}{MANIFEST_LOCK_NAME}"));
Ok(path) Ok(path)
} }

View File

@ -1151,7 +1151,7 @@ impl DataStore {
let _exclusive_lock = self.inner.chunk_store.try_exclusive_lock()?; let _exclusive_lock = self.inner.chunk_store.try_exclusive_lock()?;
let (config, _digest) = pbs_config::datastore::config()?; let (config, _digest) = pbs_config::datastore::config()?;
let gc_store_config: DataStoreConfig = config.lookup("datastore", &self.name())?; let gc_store_config: DataStoreConfig = config.lookup("datastore", self.name())?;
let all_stores = config.convert_to_typed_array("datastore")?; let all_stores = config.convert_to_typed_array("datastore")?;
if let Err(err) = gc_store_config.ensure_not_nested(&all_stores) { if let Err(err) = gc_store_config.ensure_not_nested(&all_stores) {
info!( info!(

View File

@ -240,7 +240,7 @@ async fn catalog_shell(param: Value) -> Result<(), Error> {
) )
.await?; .await?;
let state = Shell::new(None, &server_archive_name.as_ref(), accessor).await?; let state = Shell::new(None, server_archive_name.as_ref(), accessor).await?;
log::info!("Starting interactive shell"); log::info!("Starting interactive shell");
state.shell().await?; state.shell().await?;
record_repository(&repo); record_repository(&repo);
@ -283,7 +283,7 @@ async fn catalog_shell(param: Value) -> Result<(), Error> {
catalogfile.seek(SeekFrom::Start(0))?; catalogfile.seek(SeekFrom::Start(0))?;
let catalog_reader = CatalogReader::new(catalogfile); let catalog_reader = CatalogReader::new(catalogfile);
let state = Shell::new(Some(catalog_reader), &server_archive_name.as_ref(), decoder).await?; let state = Shell::new(Some(catalog_reader), server_archive_name.as_ref(), decoder).await?;
log::info!("Starting interactive shell"); log::info!("Starting interactive shell");
state.shell().await?; state.shell().await?;

View File

@ -1017,9 +1017,7 @@ async fn create_backup(
(BackupSpecificationType::PXAR, true) => { (BackupSpecificationType::PXAR, true) => {
log_file("directory", &filename, target.as_ref()) log_file("directory", &filename, target.as_ref())
} }
(BackupSpecificationType::IMAGE, true) => { (BackupSpecificationType::IMAGE, true) => log_file("image", &filename, target.as_ref()),
log_file("image", &filename, &target.as_ref())
}
// no dry-run // no dry-run
(BackupSpecificationType::CONFIG, false) => { (BackupSpecificationType::CONFIG, false) => {
let upload_options = UploadOptions { let upload_options = UploadOptions {

View File

@ -181,7 +181,7 @@ pub fn get_versions() -> Result<Vec<APTUpdateInfo>, Error> {
"proxmox-backup", "proxmox-backup",
"proxmox-backup-server", "proxmox-backup-server",
&running_daemon_version, &running_daemon_version,
&PACKAGES, PACKAGES,
) )
} }

View File

@ -290,7 +290,7 @@ pub fn create_zpool(
let mut command = std::process::Command::new("zfs"); let mut command = std::process::Command::new("zfs");
command.arg("set"); command.arg("set");
if let Some(compression) = compression { if let Some(compression) = compression {
command.arg(&format!("compression={}", compression)); command.arg(format!("compression={compression}"));
} }
command.args(["relatime=on", &name]); command.args(["relatime=on", &name]);
info!("# {command:?}"); info!("# {command:?}");

View File

@ -1215,7 +1215,7 @@ pub fn change_parttype(part_disk: &Disk, part_type: &str) -> Result<(), Error> {
let minor = unsafe { libc::minor(stat.st_rdev) }; let minor = unsafe { libc::minor(stat.st_rdev) };
let partnum_path = &format!("/sys/dev/block/{}:{}/partition", major, minor); let partnum_path = &format!("/sys/dev/block/{}:{}/partition", major, minor);
let partnum: u32 = std::fs::read_to_string(partnum_path)?.trim_end().parse()?; let partnum: u32 = std::fs::read_to_string(partnum_path)?.trim_end().parse()?;
sgdisk_command.arg(&format!("-t{}:{}", partnum, part_type)); sgdisk_command.arg(format!("-t{}:{}", partnum, part_type));
let part_disk_parent = match part_disk.parent() { let part_disk_parent = match part_disk.parent() {
Some(disk) => disk, Some(disk) => disk,
None => bail!("disk {:?} has no node in /dev", part_disk.syspath()), None => bail!("disk {:?} has no node in /dev", part_disk.syspath()),
@ -1355,7 +1355,7 @@ pub fn get_fs_uuid(disk: &Disk) -> Result<String, Error> {
/// Mount a disk by its UUID and the mount point. /// Mount a disk by its UUID and the mount point.
pub fn mount_by_uuid(uuid: &str, mount_point: &Path) -> Result<(), Error> { pub fn mount_by_uuid(uuid: &str, mount_point: &Path) -> Result<(), Error> {
let mut command = std::process::Command::new("mount"); let mut command = std::process::Command::new("mount");
command.arg(&format!("UUID={uuid}")); command.arg(format!("UUID={uuid}"));
command.arg(mount_point); command.arg(mount_point);
proxmox_sys::command::run_command(command, None)?; proxmox_sys::command::run_command(command, None)?;