all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox 0/2] rest-server: minor code cleanup
@ 2025-10-07 10:17 Filip Schauer
  2025-10-07 10:17 ` [pbs-devel] [PATCH proxmox 1/2] rest-server: simplify path concatenation Filip Schauer
  2025-10-07 10:17 ` [pbs-devel] [PATCH proxmox 2/2] rest-server: use variables directly in format strings Filip Schauer
  0 siblings, 2 replies; 3+ messages in thread
From: Filip Schauer @ 2025-10-07 10:17 UTC (permalink / raw)
  To: pbs-devel

Simplify path concatenation and fix some clippy warnings.

Filip Schauer (2):
  rest-server: simplify path concatenation
  rest-server: use variables directly in format strings

 proxmox-rest-server/src/h2service.rs   |  2 +-
 proxmox-rest-server/src/rest.rs        |  2 +-
 proxmox-rest-server/src/worker_task.rs | 30 +++++++++-----------------
 3 files changed, 12 insertions(+), 22 deletions(-)

-- 
2.47.3



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pbs-devel] [PATCH proxmox 1/2] rest-server: simplify path concatenation
  2025-10-07 10:17 [pbs-devel] [PATCH proxmox 0/2] rest-server: minor code cleanup Filip Schauer
@ 2025-10-07 10:17 ` Filip Schauer
  2025-10-07 10:17 ` [pbs-devel] [PATCH proxmox 2/2] rest-server: use variables directly in format strings Filip Schauer
  1 sibling, 0 replies; 3+ messages in thread
From: Filip Schauer @ 2025-10-07 10:17 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
 proxmox-rest-server/src/worker_task.rs | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index c9ae5243..1f9578c8 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -110,17 +110,10 @@ impl WorkerTaskSetup {
         let mut taskdir = basedir;
         taskdir.push("tasks");
 
-        let mut task_lock_fn = taskdir.clone();
-        task_lock_fn.push(".active.lock");
-
-        let mut active_tasks_fn = taskdir.clone();
-        active_tasks_fn.push("active");
-
-        let mut task_index_fn = taskdir.clone();
-        task_index_fn.push("index");
-
-        let mut task_archive_fn = taskdir.clone();
-        task_archive_fn.push("archive");
+        let task_lock_fn = taskdir.join(".active.lock");
+        let active_tasks_fn = taskdir.join("active");
+        let task_index_fn = taskdir.join("index");
+        let task_archive_fn = taskdir.join("archive");
 
         Self {
             file_opts,
@@ -146,9 +139,7 @@ impl WorkerTaskSetup {
     }
 
     fn log_directory(&self, upid: &UPID) -> std::path::PathBuf {
-        let mut path = self.taskdir.clone();
-        path.push(format!("{:02X}", upid.pstart & 255));
-        path
+        self.taskdir.join(format!("{:02X}", upid.pstart & 255))
     }
 
     fn log_path(&self, upid: &UPID) -> std::path::PathBuf {
@@ -381,8 +372,7 @@ pub fn cleanup_old_tasks(compressed: bool) -> Result<(), Error> {
         .ok_or_else(|| format_err!("could not calculate cutoff time"))?;
 
         for i in 0..256 {
-            let mut path = setup.taskdir.clone();
-            path.push(format!("{:02X}", i));
+            let path = setup.taskdir.join(format!("{i:02X}"));
             let files = match std::fs::read_dir(path) {
                 Ok(files) => files,
                 Err(err) if err.kind() == std::io::ErrorKind::NotFound => continue,
-- 
2.47.3



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pbs-devel] [PATCH proxmox 2/2] rest-server: use variables directly in format strings
  2025-10-07 10:17 [pbs-devel] [PATCH proxmox 0/2] rest-server: minor code cleanup Filip Schauer
  2025-10-07 10:17 ` [pbs-devel] [PATCH proxmox 1/2] rest-server: simplify path concatenation Filip Schauer
@ 2025-10-07 10:17 ` Filip Schauer
  1 sibling, 0 replies; 3+ messages in thread
From: Filip Schauer @ 2025-10-07 10:17 UTC (permalink / raw)
  To: pbs-devel

These changes were suggested by clippy.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
 proxmox-rest-server/src/h2service.rs   | 2 +-
 proxmox-rest-server/src/rest.rs        | 2 +-
 proxmox-rest-server/src/worker_task.rs | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/proxmox-rest-server/src/h2service.rs b/proxmox-rest-server/src/h2service.rs
index 18258e14..09843477 100644
--- a/proxmox-rest-server/src/h2service.rs
+++ b/proxmox-rest-server/src/h2service.rs
@@ -55,7 +55,7 @@ impl<E: RpcEnvironment + Clone> H2Service<E> {
             Err(err) => return future::err(http_err!(BAD_REQUEST, "{}", err)).boxed(),
         };
 
-        self.debug(format!("{} {}", method, path));
+        self.debug(format!("{method} {path}"));
 
         let mut uri_param = HashMap::new();
 
diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs
index 95060641..b76c4bc9 100644
--- a/proxmox-rest-server/src/rest.rs
+++ b/proxmox-rest-server/src/rest.rs
@@ -512,7 +512,7 @@ async fn proxy_protected_request(
     let mut request = Request::from_parts(parts, req_body);
     request.headers_mut().insert(
         header::FORWARDED,
-        format!("for=\"{}\";", peer).parse().unwrap(),
+        format!("for=\"{peer}\";").parse().unwrap(),
     );
 
     let reload_timezone = info.reload_timezone;
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 1f9578c8..84965f25 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -631,8 +631,8 @@ impl TaskState {
 
     fn result_text(&self) -> String {
         match self {
-            TaskState::Error { message, .. } => format!("TASK ERROR: {}", message),
-            other => format!("TASK {}", other),
+            TaskState::Error { message, .. } => format!("TASK ERROR: {message}"),
+            other => format!("TASK {other}"),
         }
     }
 
@@ -675,8 +675,8 @@ impl std::fmt::Display for TaskState {
         match self {
             TaskState::Unknown { .. } => write!(f, "unknown"),
             TaskState::OK { .. } => write!(f, "OK"),
-            TaskState::Warning { count, .. } => write!(f, "WARNINGS: {}", count),
-            TaskState::Error { message, .. } => write!(f, "{}", message),
+            TaskState::Warning { count, .. } => write!(f, "WARNINGS: {count}"),
+            TaskState::Error { message, .. } => write!(f, "{message}"),
         }
     }
 }
-- 
2.47.3



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-07 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-07 10:17 [pbs-devel] [PATCH proxmox 0/2] rest-server: minor code cleanup Filip Schauer
2025-10-07 10:17 ` [pbs-devel] [PATCH proxmox 1/2] rest-server: simplify path concatenation Filip Schauer
2025-10-07 10:17 ` [pbs-devel] [PATCH proxmox 2/2] rest-server: use variables directly in format strings Filip Schauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal