Skip to content

Commit

Permalink
Add "headers only" lighter dump.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Apr 22, 2024
1 parent 678bd26 commit 49f268f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ impl<F: Flash> FileManager<F> {

info!("File dump:");
for file_id in 0..FILE_COUNT {
info!("====== FILE {} ======", file_id);
if let Err(e) = self.dump_file(r, file_id as _).await {
info!("failed to dump file: {:?}", e);
}
Expand All @@ -451,17 +450,24 @@ impl<F: Flash> FileManager<F> {

#[cfg(feature = "std")]
#[allow(unused)]
pub async fn dump_file(&mut self, r: &mut PageReader, file_id: FileID) -> Result<(), Error<F::Error>> {
pub fn dump_file_header(&mut self, file_id: FileID) {
let f = self.files[file_id as usize];
info!(
" seq: {:?}..{:?} len {:?} last_page {:?} flags {:02x}",
"==== FILE {}: seq: {:?}..{:?} len {:?} last_page {:?} flags {:02x}",
file_id,
f.first_seq,
f.last_seq,
f.last_seq.sub(f.first_seq),
f.last_page.map(|p| p.page_id),
f.flags
);
}

#[cfg(feature = "std")]
#[allow(unused)]
pub async fn dump_file(&mut self, r: &mut PageReader, file_id: FileID) -> Result<(), Error<F::Error>> {
self.dump_file_header(file_id);
let f = self.files[file_id as usize];
let mut pages = Vec::new();
let mut pp = f.last_page;
while let Some(p) = pp {
Expand Down
13 changes: 11 additions & 2 deletions src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,15 +946,24 @@ impl<F: Flash> Inner<F> {

info!("File dump:");
for file_id in 0..FILE_COUNT {
info!("====== FILE {} ======", file_id);
if let Err(e) = self.dump_file(file_id as _).await {
info!("failed to dump file: {:?}", e);
}
}
}

#[cfg(feature = "std")]
pub async fn dump_file(&mut self, file_id: FileID) -> Result<(), Error<F::Error>> {
#[allow(unused)]
async fn dump_file_headers(&mut self) {
info!("============= BEGIN DUMP");

for file_id in 0..FILE_COUNT {
self.files.dump_file_header(file_id as _);
}
}

#[cfg(feature = "std")]
async fn dump_file(&mut self, file_id: FileID) -> Result<(), Error<F::Error>> {
self.files.dump_file(&mut self.readers[0], file_id).await?;

let mut r = self.files.read(&mut self.readers[0], file_id);
Expand Down

0 comments on commit 49f268f

Please sign in to comment.