all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 3/4] task_cache: Do field assigment inside initializer
Date: Mon, 13 Jan 2025 13:08:30 +0100	[thread overview]
Message-ID: <20250113120831.299244-3-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20250113120831.299244-1-m.sandoval@proxmox.com>

Fixes:

warning: field assignment outside of initializer for an instance created with Default::default()
  --> server/src/task_cache.rs:78:17
   |
78 |                 params.source = Some(ListTasksSource::All);
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: consider initializing the variable with `pve_api_types::ListTasks { source: Some(ListTasksSource::All), since: Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60), ..Default::default() }` and removing relevant reassignments
  --> server/src/task_cache.rs:76:17
   |
76 |                 let mut params = ListTasks::default();
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
   = note: `#[warn(clippy::field_reassign_with_default)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 server/src/task_cache.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/server/src/task_cache.rs b/server/src/task_cache.rs
index 2d3c9b6..3ef24b1 100644
--- a/server/src/task_cache.rs
+++ b/server/src/task_cache.rs
@@ -73,12 +73,14 @@ async fn fetch_tasks(remote: &Remote) -> Result<Vec<TaskListItem>, Error> {
             // N+1 requests - we could use /cluster/tasks, but that one
             // only gives a limited task history
             for node in client.list_nodes().await? {
-                let mut params = ListTasks::default();
-                // Include running tasks
-                params.source = Some(ListTasksSource::All);
-                // TODO: How much task history do we want? Right now we just hard-code it
-                // to 7 days.
-                params.since = Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60);
+                let params = ListTasks {
+                    // Include running tasks
+                    source: Some(ListTasksSource::All),
+                    // TODO: How much task history do we want? Right now we just hard-code it
+                    // to 7 days.
+                    since: Some(proxmox_time::epoch_i64() - 7 * 24 * 60 * 60),
+                    ..Default::default()
+                };
 
                 let list = client.get_task_list(&node.node, params).await?;
                 let mapped = map_tasks(list, &remote.id)?;
-- 
2.39.5



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


  parent reply	other threads:[~2025-01-13 12:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 12:08 [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Maximiliano Sandoval
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 2/4] remove needless borrows Maximiliano Sandoval
2025-01-13 12:08 ` Maximiliano Sandoval [this message]
2025-01-13 12:08 ` [pdm-devel] [PATCH proxmox-datacenter-manager 4/4] resources: Remove unnecessary closure Maximiliano Sandoval
2025-01-13 12:15 ` [pdm-devel] applied: [PATCH proxmox-datacenter-manager 1/4] elide lifetimes in traits when possible Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250113120831.299244-3-m.sandoval@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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