tree-wide: fix needless borrows
found and fixed via clippy Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
@ -270,7 +270,7 @@ fn dump_api_method_schema(
|
||||
|
||||
data["parameters"] = dump_property_schema(&api_method.parameters);
|
||||
|
||||
let mut returns = dump_schema(&api_method.returns.schema);
|
||||
let mut returns = dump_schema(api_method.returns.schema);
|
||||
if api_method.returns.optional {
|
||||
returns["optional"] = 1.into();
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ async fn schedule_datastore_verify_jobs() {
|
||||
let worker_type = "verificationjob";
|
||||
let auth_id = Authid::root_auth_id().clone();
|
||||
if check_schedule(worker_type, &event_str, &job_id) {
|
||||
let job = match Job::new(&worker_type, &job_id) {
|
||||
let job = match Job::new(worker_type, &job_id) {
|
||||
Ok(job) => job,
|
||||
Err(_) => continue, // could not get lock
|
||||
};
|
||||
@ -766,7 +766,7 @@ async fn schedule_tape_backup_jobs() {
|
||||
let worker_type = "tape-backup-job";
|
||||
let auth_id = Authid::root_auth_id().clone();
|
||||
if check_schedule(worker_type, &event_str, &job_id) {
|
||||
let job = match Job::new(&worker_type, &job_id) {
|
||||
let job = match Job::new(worker_type, &job_id) {
|
||||
Ok(job) => job,
|
||||
Err(_) => continue, // could not get lock
|
||||
};
|
||||
@ -1033,7 +1033,7 @@ fn check_schedule(worker_type: &str, event_str: &str, id: &str) -> bool {
|
||||
}
|
||||
};
|
||||
|
||||
let last = match jobstate::last_run_time(worker_type, &id) {
|
||||
let last = match jobstate::last_run_time(worker_type, id) {
|
||||
Ok(time) => time,
|
||||
Err(err) => {
|
||||
eprintln!("could not get last run time of {} {}: {}", worker_type, id, err);
|
||||
|
@ -94,7 +94,7 @@ async fn get_child_links(
|
||||
path: &str,
|
||||
rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Vec<String>, Error> {
|
||||
let (path, components) = normalize_uri_path(&path)?;
|
||||
let (path, components) = normalize_uri_path(path)?;
|
||||
|
||||
let info = &proxmox_backup::api2::ROUTER
|
||||
.find_route(&components, &mut HashMap::new())
|
||||
@ -132,7 +132,7 @@ fn get_api_method(
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let mut uri_param = HashMap::new();
|
||||
let (path, components) = normalize_uri_path(&path)?;
|
||||
let (path, components) = normalize_uri_path(path)?;
|
||||
if let Some(method) =
|
||||
&proxmox_backup::api2::ROUTER.find_method(&components, method.clone(), &mut uri_param)
|
||||
{
|
||||
@ -446,7 +446,7 @@ async fn ls(path: Option<String>, mut param: Value, rpcenv: &mut dyn RpcEnvironm
|
||||
&mut serde_json::to_value(res)?,
|
||||
&proxmox_schema::ReturnType {
|
||||
optional: false,
|
||||
schema: &LS_SCHEMA,
|
||||
schema: LS_SCHEMA,
|
||||
},
|
||||
&output_format,
|
||||
&options,
|
||||
|
@ -51,7 +51,7 @@ fn decode_blob(
|
||||
|
||||
if blob.is_encrypted() && key_file.is_some() {
|
||||
let (key, _created, _fingerprint) =
|
||||
load_and_decrypt_key(&key_file.unwrap(), &get_encryption_key_password)?;
|
||||
load_and_decrypt_key(key_file.unwrap(), &get_encryption_key_password)?;
|
||||
crypt_conf = CryptConfig::new(key)?;
|
||||
crypt_conf_opt = Some(&crypt_conf);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ fn recover_index(
|
||||
|
||||
let crypt_conf_opt = if let Some(key_file_path) = key_file_path {
|
||||
let (key, _created, _fingerprint) =
|
||||
load_and_decrypt_key(&key_file_path, &get_encryption_key_password)?;
|
||||
load_and_decrypt_key(key_file_path, &get_encryption_key_password)?;
|
||||
Some(CryptConfig::new(key)?)
|
||||
} else {
|
||||
None
|
||||
|
@ -55,7 +55,7 @@ fn list_acls(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Err
|
||||
pub fn acl_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&&API_METHOD_LIST_ACLS))
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_ACLS))
|
||||
.insert(
|
||||
"update",
|
||||
CliCommand::new(&api2::access::acl::API_METHOD_UPDATE_ACL)
|
||||
|
@ -93,7 +93,7 @@ async fn create_datastore(mut param: Value) -> Result<Value, Error> {
|
||||
|
||||
let mut client = connect_to_localhost()?;
|
||||
|
||||
let result = client.post(&"api2/json/config/datastore", Some(param)).await?;
|
||||
let result = client.post("api2/json/config/datastore", Some(param)).await?;
|
||||
|
||||
view_task_result(&mut client, result, &output_format).await?;
|
||||
|
||||
|
@ -73,8 +73,8 @@ fn show_openid_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Va
|
||||
pub fn openid_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&&API_METHOD_LIST_OPENID_REALMS))
|
||||
.insert("show", CliCommand::new(&&API_METHOD_SHOW_OPENID_REALM)
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_OPENID_REALMS))
|
||||
.insert("show", CliCommand::new(&API_METHOD_SHOW_OPENID_REALM)
|
||||
.arg_param(&["realm"])
|
||||
.completion_cb("realm", pbs_config::domains::complete_openid_realm_name)
|
||||
)
|
||||
|
@ -75,7 +75,7 @@ fn show_remote(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
|
||||
pub fn remote_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&&API_METHOD_LIST_REMOTES))
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_REMOTES))
|
||||
.insert(
|
||||
"show",
|
||||
CliCommand::new(&API_METHOD_SHOW_REMOTE)
|
||||
|
@ -94,7 +94,7 @@ async fn show_current_traffic(param: Value) -> Result<Value, Error> {
|
||||
|
||||
let client = connect_to_localhost()?;
|
||||
|
||||
let mut result = client.get(&"api2/json/admin/traffic-control", None).await?;
|
||||
let mut result = client.get("api2/json/admin/traffic-control", None).await?;
|
||||
|
||||
let mut data = result["data"].take();
|
||||
|
||||
|
@ -171,7 +171,7 @@ fn list_permissions(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Val
|
||||
pub fn user_commands() -> CommandLineInterface {
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&&API_METHOD_LIST_USERS))
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_USERS))
|
||||
.insert(
|
||||
"create",
|
||||
// fixme: howto handle password parameter?
|
||||
@ -192,7 +192,7 @@ pub fn user_commands() -> CommandLineInterface {
|
||||
)
|
||||
.insert(
|
||||
"list-tokens",
|
||||
CliCommand::new(&&API_METHOD_LIST_TOKENS)
|
||||
CliCommand::new(&API_METHOD_LIST_TOKENS)
|
||||
.arg_param(&["userid"])
|
||||
.completion_cb("userid", pbs_config::user::complete_userid)
|
||||
)
|
||||
@ -211,7 +211,7 @@ pub fn user_commands() -> CommandLineInterface {
|
||||
)
|
||||
.insert(
|
||||
"permissions",
|
||||
CliCommand::new(&&API_METHOD_LIST_PERMISSIONS)
|
||||
CliCommand::new(&API_METHOD_LIST_PERMISSIONS)
|
||||
.arg_param(&["auth-id"])
|
||||
.completion_cb("auth-id", pbs_config::user::complete_authid)
|
||||
.completion_cb("path", pbs_config::datastore::complete_acl_path)
|
||||
|
@ -34,12 +34,12 @@ fn get_tape_handle(param: &Value) -> Result<LtoTapeHandle, Error> {
|
||||
|
||||
let handle = if let Some(name) = param["drive"].as_str() {
|
||||
let (config, _digest) = pbs_config::drive::config()?;
|
||||
let drive: LtoTapeDrive = config.lookup("lto", &name)?;
|
||||
let drive: LtoTapeDrive = config.lookup("lto", name)?;
|
||||
eprintln!("using device {}", drive.path);
|
||||
open_lto_tape_drive(&drive)?
|
||||
} else if let Some(device) = param["device"].as_str() {
|
||||
eprintln!("using device {}", device);
|
||||
LtoTapeHandle::new(open_lto_tape_device(&device)?)?
|
||||
LtoTapeHandle::new(open_lto_tape_device(device)?)?
|
||||
} else if let Some(true) = param["stdin"].as_bool() {
|
||||
eprintln!("using stdin");
|
||||
let fd = std::io::stdin().as_raw_fd();
|
||||
@ -62,7 +62,7 @@ fn get_tape_handle(param: &Value) -> Result<LtoTapeHandle, Error> {
|
||||
|
||||
if drive_names.len() == 1 {
|
||||
let name = drive_names[0];
|
||||
let drive: LtoTapeDrive = config.lookup("lto", &name)?;
|
||||
let drive: LtoTapeDrive = config.lookup("lto", name)?;
|
||||
eprintln!("using device {}", drive.path);
|
||||
open_lto_tape_drive(&drive)?
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user