Skip to content

Commit

Permalink
Avoid a bug when saving an empty capture.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinling committed Sep 21, 2024
1 parent 97abde7 commit ef1d62f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,14 @@ where
let packet_count = capture.packet_index.len();
let meta = capture.shared.metadata.load_full();
let mut saver = Saver::new(dest, meta)?;
for (result, i) in capture.timestamped_packets()?.zip(0..packet_count) {
let (timestamp_ns, packet) = result?;
saver.add_packet(&packet, timestamp_ns)?;
CURRENT.store(i + 1, Ordering::Relaxed);
if STOP.load(Ordering::Relaxed) {
break;
if packet_count > 0 {
for (result, i) in capture.timestamped_packets()?.zip(0..packet_count) {
let (timestamp_ns, packet) = result?;
saver.add_packet(&packet, timestamp_ns)?;
CURRENT.store(i + 1, Ordering::Relaxed);
if STOP.load(Ordering::Relaxed) {
break;
}
}
}
saver.close()
Expand Down

0 comments on commit ef1d62f

Please sign in to comment.