public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-offline-mirror 2/2] mirror: collect and summarize warnings
Date: Fri, 23 Sep 2022 12:33:52 +0200	[thread overview]
Message-ID: <20220923103352.569770-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20220923103352.569770-1-f.gruenbichler@proxmox.com>

the output can get quite long and warnings can easily be missed
otherwise.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/mirror.rs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/mirror.rs b/src/mirror.rs
index e655847..f8afd2b 100644
--- a/src/mirror.rs
+++ b/src/mirror.rs
@@ -494,6 +494,7 @@ pub fn create_snapshot(
     let prefix = Path::new(&prefix);
 
     let mut total_progress = Progress::new();
+    let mut warnings = Vec::new();
 
     let parse_release = |res: FetchResult, name: &str| -> Result<ReleaseFile, Error> {
         println!("Parsing {name}..");
@@ -624,10 +625,12 @@ pub fn create_snapshot(
                 ) {
                     Ok(res) => res,
                     Err(err) if !reference.file_type.is_package_index() => {
-                        eprintln!(
+                        let msg = format!(
                             "Failed to fetch '{:?}' type reference '{}', skipping - {err}",
                             reference.file_type, reference.path
                         );
+                        eprintln!("{msg}");
+                        warnings.push(msg);
                         failed_references.push(reference);
                         continue;
                     }
@@ -709,6 +712,7 @@ pub fn create_snapshot(
                             basename, package.file, err,
                         );
                         eprintln!("{msg}");
+                        warnings.push(msg);
                     }
                     res => {
                         res?;
@@ -735,8 +739,15 @@ pub fn create_snapshot(
         println!("\nStats: {total_progress}");
     }
 
+    if !warnings.is_empty() {
+        eprintln!("Warnings:");
+        for msg in warnings {
+            eprintln!("- {msg}");
+        }
+    }
+
     if !dry_run {
-        println!("Rotating temp. snapshot in-place: {prefix:?} -> \"{snapshot}\"");
+        println!("\nRotating temp. snapshot in-place: {prefix:?} -> \"{snapshot}\"");
         let locked = config.pool.lock()?;
         locked.rename(prefix, Path::new(&format!("{snapshot}")))?;
     }
-- 
2.30.2





  reply	other threads:[~2022-09-23 10:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23 10:33 [pve-devel] [PATCH proxmox-offline-mirror 1/2] fix #4259: mirror: add ignore-errors option Fabian Grünbichler
2022-09-23 10:33 ` Fabian Grünbichler [this message]
2022-09-23 12:30 ` [pve-devel] applied: " Wolfgang Bumiller

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=20220923103352.569770-2-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal