From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/3] debug: recover: allow overriding output-path
Date: Mon, 23 May 2022 16:11:35 +0200 [thread overview]
Message-ID: <20220523141135.921321-3-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20220523141135.921321-1-f.gruenbichler@proxmox.com>
including to STDOUT.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
src/bin/proxmox_backup_debug/recover.rs | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/bin/proxmox_backup_debug/recover.rs b/src/bin/proxmox_backup_debug/recover.rs
index 9c4aed3d..23366b86 100644
--- a/src/bin/proxmox_backup_debug/recover.rs
+++ b/src/bin/proxmox_backup_debug/recover.rs
@@ -51,6 +51,11 @@ use pbs_tools::crypt_config::CryptConfig;
optional: true,
default: false,
},
+ "output-path": {
+ type: String,
+ description: "Output file path, defaults to `file` without extension, '-' means STDOUT.",
+ optional: true,
+ },
}
}
)]
@@ -63,6 +68,7 @@ fn recover_index(
skip_crc: bool,
ignore_missing_chunks: bool,
ignore_corrupt_chunks: bool,
+ output_path: Option<String>,
_param: Value,
) -> Result<(), Error> {
let file_path = Path::new(&file);
@@ -92,9 +98,16 @@ fn recover_index(
None
};
- let output_filename = file_path.file_stem().unwrap().to_str().unwrap();
- let output_path = Path::new(output_filename);
- let mut output_file = File::create(output_path)
+ let output_path = output_path.unwrap_or_else(|| {
+ let filename = file_path.file_stem().unwrap().to_str().unwrap();
+ filename.to_string()
+ });
+
+ let output_path = match output_path.as_str() {
+ "-" => None,
+ path => Some(path),
+ };
+ let mut output_file = crate::outfile_or_stdout(output_path)
.map_err(|e| format_err!("could not create output file - {}", e))?;
let mut data = Vec::with_capacity(4 * 1024 * 1024);
--
2.30.2
next prev parent reply other threads:[~2022-05-23 14:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 14:11 [pbs-devel] [PATCH proxmox-backup 1/3] debug: recover: allow ignoring missing/corrupt chunks Fabian Grünbichler
2022-05-23 14:11 ` [pbs-devel] [PATCH proxmox-backup 2/3] debug: move outfile_or_stdout to module for reuse Fabian Grünbichler
2022-05-23 14:11 ` Fabian Grünbichler [this message]
2022-05-24 9:16 ` [pbs-devel] [PATCH proxmox-backup 1/3] debug: recover: allow ignoring missing/corrupt chunks Hannes Laimer
2022-05-24 9:47 ` [pbs-devel] applied-series: " Thomas Lamprecht
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=20220523141135.921321-3-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-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