Fix a bug in experimental mmap storage
This commit is contained in:
parent
3b0987ec23
commit
108ad74464
2 changed files with 23 additions and 3 deletions
18
.zed/settings.json
Normal file
18
.zed/settings.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Folder-specific settings
|
||||
//
|
||||
// For a full list of overridable settings, and general information on folder-specific settings,
|
||||
// see the documentation: https://zed.dev/docs/configuring-zed#folder-specific-settings
|
||||
{
|
||||
"lsp": {
|
||||
"rust-analyzer": {
|
||||
"initialization_options": {
|
||||
"check": {
|
||||
"command": "clippy" // rust-analyzer.check.command (default: "check")
|
||||
},
|
||||
"cargo": {
|
||||
"features": ["librqbit/storage_middleware"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,9 +25,11 @@ impl StorageFactory for MmapFilesystemStorageFactory {
|
|||
fn init_storage(&self, meta: &ManagedTorrentInfo) -> anyhow::Result<Self::Storage> {
|
||||
let fs_storage = FilesystemStorageFactory::default().init_storage(meta)?;
|
||||
let mut mmaps = Vec::new();
|
||||
for file in fs_storage.opened_files.iter() {
|
||||
let mmap = unsafe { MmapOptions::new().map_mut(&*file.file.read()) }
|
||||
.context("error mapping file")?;
|
||||
for (idx, file) in fs_storage.opened_files.iter().enumerate() {
|
||||
let fg = file.file.write();
|
||||
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")?;
|
||||
mmaps.push(RwLock::new(mmap));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue