Fix reading.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{self, Seek, SeekFrom};
|
||||
use std::os::unix::fs::{FileExt, OpenOptionsExt};
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
|
||||
use crate::cli::CONFIG;
|
||||
|
||||
@@ -23,7 +23,7 @@ pub fn get_stream_length<S: Seek>(stream: &mut S) -> io::Result<u64> {
|
||||
pub fn load_input() -> anyhow::Result<File> {
|
||||
OpenOptions::new()
|
||||
.read(true)
|
||||
//.custom_flags(libc::O_DIRECT)
|
||||
.custom_flags(libc::O_DIRECT)
|
||||
.open(&CONFIG.input)
|
||||
.with_context(|| format!("Failed to open input file: {}", &CONFIG.input.display()))
|
||||
|
||||
|
||||
@@ -94,14 +94,18 @@ impl Recover {
|
||||
// Caching.
|
||||
let mut read_position: usize;
|
||||
let mut cluster: Cluster;
|
||||
let mut buf: Vec<u8>;
|
||||
let mut buf_capacity = self.get_buf_capacity() as usize;
|
||||
let mut buf = vec![crate::FB_NULL_VALUE; buf_capacity];
|
||||
|
||||
dbg!(untested.domain);
|
||||
read_position = untested.domain.start;
|
||||
|
||||
while read_position < untested.domain.end {
|
||||
dbg!(read_position);
|
||||
|
||||
buf_capacity = buf_capacity.min(untested.domain.end - read_position);
|
||||
buf = vec![crate::FB_NULL_VALUE; buf_capacity];
|
||||
|
||||
cluster = Cluster {
|
||||
domain: Domain {
|
||||
start: read_position,
|
||||
@@ -110,8 +114,6 @@ impl Recover {
|
||||
stage: Stage::Intact,
|
||||
};
|
||||
|
||||
buf_capacity = buf_capacity.min(untested.domain.end - read_position);
|
||||
|
||||
if let Err(err) = self.input.read_exact(&mut buf) {
|
||||
// If buf were zeroed out before every read, one could theoretically recover
|
||||
// part of that read given the assumption that all null values from the end to
|
||||
|
||||
Reference in New Issue
Block a user