mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-10-17 22:46:36 +00:00
clippy/fmt: tree wide drop of clone for types implementing copy
fixes the clippy warning on types T implementing Copy: ``` warning: using `clone` on type `T` which implements the `Copy` trait ``` followed by formatting fixups via `cargo fmt`. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
7c45cf8c7a
commit
3362a6e049
@ -101,7 +101,7 @@ impl ConfigVersionCache {
|
|||||||
let file_path = Path::new(FILE_PATH);
|
let file_path = Path::new(FILE_PATH);
|
||||||
let dir_path = file_path.parent().unwrap();
|
let dir_path = file_path.parent().unwrap();
|
||||||
|
|
||||||
create_path(dir_path, Some(dir_opts.clone()), Some(dir_opts))?;
|
create_path(dir_path, Some(dir_opts), Some(dir_opts))?;
|
||||||
|
|
||||||
let file_opts = CreateOptions::new()
|
let file_opts = CreateOptions::new()
|
||||||
.perm(Mode::from_bits_truncate(0o660))
|
.perm(Mode::from_bits_truncate(0o660))
|
||||||
|
@ -109,7 +109,7 @@ impl ChunkStore {
|
|||||||
|
|
||||||
let default_options = CreateOptions::new();
|
let default_options = CreateOptions::new();
|
||||||
|
|
||||||
match create_path(&base, Some(default_options), Some(options.clone())) {
|
match create_path(&base, Some(default_options), Some(options)) {
|
||||||
Err(err) => bail!("unable to create chunk store '{name}' at {base:?} - {err}"),
|
Err(err) => bail!("unable to create chunk store '{name}' at {base:?} - {err}"),
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
if !res {
|
if !res {
|
||||||
@ -118,13 +118,13 @@ impl ChunkStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = create_dir(&chunk_dir, options.clone()) {
|
if let Err(err) = create_dir(&chunk_dir, options) {
|
||||||
bail!("unable to create chunk store '{name}' subdir {chunk_dir:?} - {err}");
|
bail!("unable to create chunk store '{name}' subdir {chunk_dir:?} - {err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create lock file with correct owner/group
|
// create lock file with correct owner/group
|
||||||
let lockfile_path = Self::lockfile_path(&base);
|
let lockfile_path = Self::lockfile_path(&base);
|
||||||
proxmox_sys::fs::replace_file(lockfile_path, b"", options.clone(), false)?;
|
proxmox_sys::fs::replace_file(lockfile_path, b"", options, false)?;
|
||||||
|
|
||||||
// create 64*1024 subdirs
|
// create 64*1024 subdirs
|
||||||
let mut last_percentage = 0;
|
let mut last_percentage = 0;
|
||||||
@ -132,7 +132,7 @@ impl ChunkStore {
|
|||||||
for i in 0..64 * 1024 {
|
for i in 0..64 * 1024 {
|
||||||
let mut l1path = chunk_dir.clone();
|
let mut l1path = chunk_dir.clone();
|
||||||
l1path.push(format!("{:04x}", i));
|
l1path.push(format!("{:04x}", i));
|
||||||
if let Err(err) = create_dir(&l1path, options.clone()) {
|
if let Err(err) = create_dir(&l1path, options) {
|
||||||
bail!(
|
bail!(
|
||||||
"unable to create chunk store '{}' subdir {:?} - {}",
|
"unable to create chunk store '{}' subdir {:?} - {}",
|
||||||
name,
|
name,
|
||||||
|
@ -47,7 +47,7 @@ fn open_lock_file(name: &str) -> Result<(std::fs::File, CreateOptions), Error> {
|
|||||||
let timeout = std::time::Duration::new(10, 0);
|
let timeout = std::time::Duration::new(10, 0);
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
open_file_locked(lock_path, timeout, true, options.clone())?,
|
open_file_locked(lock_path, timeout, true, options)?,
|
||||||
options,
|
options,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -2416,19 +2416,11 @@ fn setup_mounted_device(datastore: &DataStoreConfig, tmp_mount_path: &str) -> Re
|
|||||||
.owner(backup_user.uid)
|
.owner(backup_user.uid)
|
||||||
.group(backup_user.gid);
|
.group(backup_user.gid);
|
||||||
|
|
||||||
proxmox_sys::fs::create_path(
|
proxmox_sys::fs::create_path(&mount_point, Some(default_options), Some(options))
|
||||||
&mount_point,
|
|
||||||
Some(default_options.clone()),
|
|
||||||
Some(options.clone()),
|
|
||||||
)
|
|
||||||
.map_err(|e| format_err!("creating mountpoint '{mount_point}' failed: {e}"))?;
|
.map_err(|e| format_err!("creating mountpoint '{mount_point}' failed: {e}"))?;
|
||||||
|
|
||||||
// can't be created before it is mounted, so we have to do it here
|
// can't be created before it is mounted, so we have to do it here
|
||||||
proxmox_sys::fs::create_path(
|
proxmox_sys::fs::create_path(&full_store_path, Some(default_options), Some(options))
|
||||||
&full_store_path,
|
|
||||||
Some(default_options.clone()),
|
|
||||||
Some(options.clone()),
|
|
||||||
)
|
|
||||||
.map_err(|e| format_err!("creating datastore path '{full_store_path}' failed: {e}"))?;
|
.map_err(|e| format_err!("creating datastore path '{full_store_path}' failed: {e}"))?;
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
@ -2468,8 +2460,8 @@ pub fn do_mount_device(datastore: DataStoreConfig) -> Result<(), Error> {
|
|||||||
let default_options = proxmox_sys::fs::CreateOptions::new();
|
let default_options = proxmox_sys::fs::CreateOptions::new();
|
||||||
proxmox_sys::fs::create_path(
|
proxmox_sys::fs::create_path(
|
||||||
&tmp_mount_path,
|
&tmp_mount_path,
|
||||||
Some(default_options.clone()),
|
Some(default_options),
|
||||||
Some(default_options.clone()),
|
Some(default_options),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
info!("temporarily mounting '{uuid}' to '{}'", tmp_mount_path);
|
info!("temporarily mounting '{uuid}' to '{}'", tmp_mount_path);
|
||||||
|
@ -88,21 +88,21 @@ async fn run() -> Result<(), Error> {
|
|||||||
.default_api2_handler(&proxmox_backup::api2::ROUTER)
|
.default_api2_handler(&proxmox_backup::api2::ROUTER)
|
||||||
.enable_access_log(
|
.enable_access_log(
|
||||||
pbs_buildcfg::API_ACCESS_LOG_FN,
|
pbs_buildcfg::API_ACCESS_LOG_FN,
|
||||||
Some(dir_opts.clone()),
|
Some(dir_opts),
|
||||||
Some(file_opts.clone()),
|
Some(file_opts),
|
||||||
&mut command_sock,
|
&mut command_sock,
|
||||||
)?
|
)?
|
||||||
.enable_auth_log(
|
.enable_auth_log(
|
||||||
pbs_buildcfg::API_AUTH_LOG_FN,
|
pbs_buildcfg::API_AUTH_LOG_FN,
|
||||||
Some(dir_opts.clone()),
|
Some(dir_opts),
|
||||||
Some(file_opts.clone()),
|
Some(file_opts),
|
||||||
&mut command_sock,
|
&mut command_sock,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let rest_server = RestServer::new(config);
|
let rest_server = RestServer::new(config);
|
||||||
proxmox_rest_server::init_worker_tasks(
|
proxmox_rest_server::init_worker_tasks(
|
||||||
pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(),
|
pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(),
|
||||||
file_opts.clone(),
|
file_opts,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// http server future:
|
// http server future:
|
||||||
|
@ -223,14 +223,14 @@ async fn run() -> Result<(), Error> {
|
|||||||
config = config
|
config = config
|
||||||
.enable_access_log(
|
.enable_access_log(
|
||||||
pbs_buildcfg::API_ACCESS_LOG_FN,
|
pbs_buildcfg::API_ACCESS_LOG_FN,
|
||||||
Some(dir_opts.clone()),
|
Some(dir_opts),
|
||||||
Some(file_opts.clone()),
|
Some(file_opts),
|
||||||
&mut command_sock,
|
&mut command_sock,
|
||||||
)?
|
)?
|
||||||
.enable_auth_log(
|
.enable_auth_log(
|
||||||
pbs_buildcfg::API_AUTH_LOG_FN,
|
pbs_buildcfg::API_AUTH_LOG_FN,
|
||||||
Some(dir_opts.clone()),
|
Some(dir_opts),
|
||||||
Some(file_opts.clone()),
|
Some(file_opts),
|
||||||
&mut command_sock,
|
&mut command_sock,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
let redirector = Redirector::new();
|
let redirector = Redirector::new();
|
||||||
proxmox_rest_server::init_worker_tasks(
|
proxmox_rest_server::init_worker_tasks(
|
||||||
pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(),
|
pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(),
|
||||||
file_opts.clone(),
|
file_opts,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
//openssl req -x509 -newkey rsa:4096 -keyout /etc/proxmox-backup/proxy.key -out /etc/proxmox-backup/proxy.pem -nodes
|
//openssl req -x509 -newkey rsa:4096 -keyout /etc/proxmox-backup/proxy.key -out /etc/proxmox-backup/proxy.pem -nodes
|
||||||
@ -752,7 +752,7 @@ async fn schedule_task_log_rotate() {
|
|||||||
true,
|
true,
|
||||||
Some(max_files),
|
Some(max_files),
|
||||||
max_days,
|
max_days,
|
||||||
Some(options.clone()),
|
Some(options),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if has_rotated {
|
if has_rotated {
|
||||||
@ -768,7 +768,7 @@ async fn schedule_task_log_rotate() {
|
|||||||
pbs_buildcfg::API_ACCESS_LOG_FN,
|
pbs_buildcfg::API_ACCESS_LOG_FN,
|
||||||
true,
|
true,
|
||||||
Some(max_files),
|
Some(max_files),
|
||||||
Some(options.clone()),
|
Some(options),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if logrotate.rotate(max_size)? {
|
if logrotate.rotate(max_size)? {
|
||||||
|
@ -95,7 +95,7 @@ async fn run(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
|
|||||||
.group(backup_user.gid);
|
.group(backup_user.gid);
|
||||||
proxmox_rest_server::init_worker_tasks(
|
proxmox_rest_server::init_worker_tasks(
|
||||||
pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(),
|
pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(),
|
||||||
file_opts.clone(),
|
file_opts,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut command_sock = proxmox_daemon::command_socket::CommandSocket::new(backup_user.gid);
|
let mut command_sock = proxmox_daemon::command_socket::CommandSocket::new(backup_user.gid);
|
||||||
|
@ -409,8 +409,8 @@ fn inspect_device(device: String, param: Value) -> Result<(), Error> {
|
|||||||
let default_options = proxmox_sys::fs::CreateOptions::new();
|
let default_options = proxmox_sys::fs::CreateOptions::new();
|
||||||
proxmox_sys::fs::create_path(
|
proxmox_sys::fs::create_path(
|
||||||
&tmp_mount_path,
|
&tmp_mount_path,
|
||||||
Some(default_options.clone()),
|
Some(default_options),
|
||||||
Some(default_options.clone()),
|
Some(default_options),
|
||||||
)?;
|
)?;
|
||||||
let mut mount_cmd = std::process::Command::new("mount");
|
let mut mount_cmd = std::process::Command::new("mount");
|
||||||
mount_cmd.arg(device.clone());
|
mount_cmd.arg(device.clone());
|
||||||
|
@ -199,14 +199,15 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
|
|||||||
fn open(&self, userid: &str) -> Result<Box<dyn UserChallengeAccess>, Error> {
|
fn open(&self, userid: &str) -> Result<Box<dyn UserChallengeAccess>, Error> {
|
||||||
crate::server::create_run_dir()?;
|
crate::server::create_run_dir()?;
|
||||||
let options = CreateOptions::new().perm(Mode::from_bits_truncate(0o0600));
|
let options = CreateOptions::new().perm(Mode::from_bits_truncate(0o0600));
|
||||||
proxmox_sys::fs::create_path(CHALLENGE_DATA_PATH, Some(options.clone()), Some(options))
|
proxmox_sys::fs::create_path(CHALLENGE_DATA_PATH, Some(options), Some(options)).map_err(
|
||||||
.map_err(|err| {
|
|err| {
|
||||||
format_err!(
|
format_err!(
|
||||||
"failed to crate challenge data dir {:?}: {}",
|
"failed to crate challenge data dir {:?}: {}",
|
||||||
CHALLENGE_DATA_PATH,
|
CHALLENGE_DATA_PATH,
|
||||||
err
|
err
|
||||||
)
|
)
|
||||||
})?;
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
let path = challenge_data_path_str(userid);
|
let path = challenge_data_path_str(userid);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ pub fn create_jobstate_dir() -> Result<(), Error> {
|
|||||||
.owner(backup_user.uid)
|
.owner(backup_user.uid)
|
||||||
.group(backup_user.gid);
|
.group(backup_user.gid);
|
||||||
|
|
||||||
create_path(JOB_STATE_BASEDIR, Some(opts.clone()), Some(opts))
|
create_path(JOB_STATE_BASEDIR, Some(opts), Some(opts))
|
||||||
.map_err(|err: Error| format_err!("unable to create job state dir - {err}"))?;
|
.map_err(|err: Error| format_err!("unable to create job state dir - {err}"))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -80,7 +80,7 @@ impl SharedRateLimiter {
|
|||||||
.owner(user.uid)
|
.owner(user.uid)
|
||||||
.group(user.gid);
|
.group(user.gid);
|
||||||
|
|
||||||
create_path(&path, Some(dir_opts.clone()), Some(dir_opts))?;
|
create_path(&path, Some(dir_opts), Some(dir_opts))?;
|
||||||
|
|
||||||
path.push(name);
|
path.push(name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user