Skip to content

Commit 591fa1f

Browse files
committed
don't switch to heuristic mode for noop-seeks
these regularely happen to find the current position in the file
1 parent 6f72c02 commit 591fa1f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/iter.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,14 @@ impl<W: io::Write> io::Write for ProgressBarIter<W> {
353353

354354
impl<S: io::Seek> io::Seek for ProgressBarIter<S> {
355355
fn seek(&mut self, f: io::SeekFrom) -> io::Result<u64> {
356-
self.it.seek(f).map(|pos| {
357-
let pos = if self.hold_max {
358-
self.progress.position().max(pos)
359-
} else {
356+
if let io::SeekFrom::Current(0) = f {
357+
self.it.seek(f)
358+
} else {
359+
self.it.seek(f).map(|pos| {
360+
self.progress.set_position(self.hold_max.update_seek(pos));
360361
pos
361-
};
362-
self.progress.set_position(pos);
363-
self.progress.set_position(self.hold_max.update_seek(pos));
364-
pos
365-
})
362+
})
363+
}
366364
}
367365
// Pass this through to preserve optimizations that the inner I/O object may use here
368366
// Also avoid sending a set_position update when the position hasn't changed

0 commit comments

Comments
 (0)