Fix reading.

This commit is contained in:
Cutieguwu
2026-01-01 01:09:41 -05:00
parent 7537107144
commit 2df9e8e0f2
2 changed files with 7 additions and 5 deletions

View File

@@ -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()))

View File

@@ -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