dummy file is Option now instead of additional open

This commit is contained in:
Igor Katson 2024-08-19 11:25:45 +01:00
parent c1775e45eb
commit 60f831bc6f
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
3 changed files with 30 additions and 26 deletions

View file

@ -102,9 +102,10 @@ impl TorrentStorage for MmapFilesystemStorage {
let mut mmaps = Vec::new();
for (idx, file) in self.fs.opened_files.iter().enumerate() {
let fg = file.file.write();
let fg = fg.as_ref().context("file is None")?;
fg.set_len(meta.file_infos[idx].len)
.context("mmap storage: error setting length")?;
let mmap = unsafe { MmapOptions::new().map_mut(&*fg) }.context("error mapping file")?;
let mmap = unsafe { MmapOptions::new().map_mut(fg) }.context("error mapping file")?;
mmaps.push(RwLock::new(mmap));
}