[pbs-devel] [PATCH v6 proxmox-backup 24/29] tools: add optional path prefix to line based output
Christian Ebner
c.ebner at proxmox.com
Thu Jan 25 14:26:03 CET 2024
By default, the shown path is the one stored in the entry.
When printing pxar entries from the appendix section, that path is
however incomplete and has to be prefixed by the base path.
Allow to pass this base path to be shown as prefix to path stored in
the entry itself.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
Changes since v5:
- not present in previous version
pbs-client/src/pxar/tools.rs | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/pbs-client/src/pxar/tools.rs b/pbs-client/src/pxar/tools.rs
index 52e025e4..0f44b5dd 100644
--- a/pbs-client/src/pxar/tools.rs
+++ b/pbs-client/src/pxar/tools.rs
@@ -123,7 +123,7 @@ fn format_mtime(mtime: &StatxTimestamp) -> String {
format!("{}.{}", mtime.secs, mtime.nanos)
}
-pub fn format_single_line_entry(entry: &Entry) -> String {
+pub fn format_single_line_entry(entry: &Entry, base_path: Option<&Path>) -> String {
let mode_string = mode_string(entry);
let meta = entry.metadata();
@@ -138,14 +138,14 @@ pub fn format_single_line_entry(entry: &Entry) -> String {
let owner_string = format!("{}/{}", meta.stat.uid, meta.stat.gid);
+ let path = match base_path {
+ Some(base_path) => base_path.join(entry.path().strip_prefix("/").unwrap()),
+ None => entry.path().to_path_buf(),
+ };
+
format!(
- "{} {:<13} {} {:>8} {:?}{}",
- mode_string,
- owner_string,
+ "{mode_string} {owner_string:<13} {} {size:>8} {path:?}{link}",
format_mtime(&meta.stat.mtime),
- size,
- entry.path(),
- link,
)
}
--
2.39.2
More information about the pbs-devel
mailing list