use std::sync::Arc;
use std::io::{Read, Write};
+use std::fs::File;
use std::path::{Path, PathBuf};
use std::os::unix::io::AsRawFd;
use uuid::Uuid;
pub struct FixedIndexReader {
store: Arc<ChunkStore>,
+ _file: File,
filename: PathBuf,
chunk_size: usize,
pub size: usize,
let full_path = store.relative_path(path);
- let mut file = std::fs::File::open(&full_path)?;
+ let mut file = File::open(&full_path)?;
if let Err(err) = nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) {
bail!("unable to get shared lock on {:?} - {}", full_path, err);
Ok(Self {
store,
filename: full_path,
+ _file: file,
chunk_size,
size,
index: data,