mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
feat(commands): Add list indexpacks and list indexcontent commands (#1254)
This allows better analysis of reported bugs related to the index.
This commit is contained in:
parent
f5499db21b
commit
5ec9652511
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -3721,7 +3721,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rustic_backend"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/rustic-rs/rustic_core.git#1c5f527c220fb77eecb85b6d4ba262063076b2aa"
|
||||
source = "git+https://github.com/rustic-rs/rustic_core.git#bf29cd88c178388b491853c1dc6e09ec03401fb1"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"anyhow",
|
||||
@ -3807,7 +3807,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rustic_core"
|
||||
version = "0.3.1"
|
||||
source = "git+https://github.com/rustic-rs/rustic_core.git#1c5f527c220fb77eecb85b6d4ba262063076b2aa"
|
||||
source = "git+https://github.com/rustic-rs/rustic_core.git#bf29cd88c178388b491853c1dc6e09ec03401fb1"
|
||||
dependencies = [
|
||||
"aes256ctr_poly1305aes",
|
||||
"anyhow",
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
//! `list` subcommand
|
||||
|
||||
use std::num::NonZero;
|
||||
|
||||
use crate::{commands::open_repository, status_err, Application, RUSTIC_APP};
|
||||
|
||||
use abscissa_core::{Command, Runnable, Shutdown};
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use rustic_core::repofile::{IndexFile, IndexId, KeyId, PackId, SnapshotId};
|
||||
@ -12,7 +13,7 @@ use rustic_core::repofile::{IndexFile, IndexId, KeyId, PackId, SnapshotId};
|
||||
#[derive(clap::Parser, Command, Debug)]
|
||||
pub(crate) struct ListCmd {
|
||||
/// File types to list
|
||||
#[clap(value_parser=["blobs", "index", "packs", "snapshots", "keys"])]
|
||||
#[clap(value_parser=["blobs", "indexpacks", "indexcontent", "index", "packs", "snapshots", "keys"])]
|
||||
tpe: String,
|
||||
}
|
||||
|
||||
@ -32,14 +33,43 @@ impl ListCmd {
|
||||
|
||||
match self.tpe.as_str() {
|
||||
// special treatment for listing blobs: read the index and display it
|
||||
"blobs" => {
|
||||
"blobs" | "indexpacks" | "indexcontent" => {
|
||||
for item in repo.stream_files::<IndexFile>()? {
|
||||
let (_, index) = item?;
|
||||
index.packs.into_iter().for_each(|pack| {
|
||||
for blob in pack.blobs {
|
||||
println!("{:?} {:?}", blob.tpe, blob.id);
|
||||
for pack in index.packs {
|
||||
match self.tpe.as_str() {
|
||||
"blobs" => {
|
||||
for blob in pack.blobs {
|
||||
println!("{:?} {:?}", blob.tpe, blob.id);
|
||||
}
|
||||
}
|
||||
"indexcontent" => {
|
||||
for blob in pack.blobs {
|
||||
println!(
|
||||
"{:?} {:?} {:?} {} {}",
|
||||
blob.tpe,
|
||||
blob.id,
|
||||
pack.id,
|
||||
blob.length,
|
||||
blob.uncompressed_length.map_or(0, NonZero::get)
|
||||
);
|
||||
}
|
||||
}
|
||||
"indexpacks" => println!(
|
||||
"{:?} {:?} {} {}",
|
||||
pack.blob_type(),
|
||||
pack.id,
|
||||
pack.pack_size(),
|
||||
pack.time.map_or_else(String::new, |time| format!(
|
||||
"{}",
|
||||
time.format("%Y-%m-%d %H:%M:%S")
|
||||
))
|
||||
),
|
||||
t => {
|
||||
bail!("invalid type: {}", t);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
"index" => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user