Force set file length on stream
This commit is contained in:
parent
ea2dfd0500
commit
0ebd4aa128
2 changed files with 8 additions and 7 deletions
|
|
@ -16,10 +16,6 @@ use crate::{
|
|||
|
||||
use super::{paused::TorrentStatePaused, ManagedTorrentInfo};
|
||||
|
||||
fn ensure_file_length(file: &File, length: u64) -> anyhow::Result<()> {
|
||||
Ok(file.set_len(length)?)
|
||||
}
|
||||
|
||||
pub struct TorrentStateInitializing {
|
||||
pub(crate) meta: Arc<ManagedTorrentInfo>,
|
||||
pub(crate) only_files: Option<Vec<usize>>,
|
||||
|
|
@ -107,7 +103,7 @@ impl TorrentStateInitializing {
|
|||
.unwrap_or(true)
|
||||
{
|
||||
let now = Instant::now();
|
||||
if let Err(err) = ensure_file_length(&file.file.lock(), file.len) {
|
||||
if let Err(err) = file.file.lock().set_len(file.len) {
|
||||
warn!(
|
||||
"Error setting length for file {:?} to {}: {:#?}",
|
||||
file.filename, file.len, err
|
||||
|
|
|
|||
|
|
@ -343,8 +343,13 @@ impl ManagedTorrent {
|
|||
torrent: self,
|
||||
};
|
||||
if s.torrent.maybe_reconnect_needed_peers_for_file(file_id) {
|
||||
s.torrent
|
||||
.with_opened_file(file_id, |fd| fd.reopen(false))??;
|
||||
s.torrent.with_opened_file(file_id, |fd| {
|
||||
fd.reopen(false)?;
|
||||
fd.file
|
||||
.lock()
|
||||
.set_len(fd.len)
|
||||
.context("error setting file length")
|
||||
})??;
|
||||
}
|
||||
streams.streams.insert(
|
||||
s.stream_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue