Nothing, small cleanups
This commit is contained in:
parent
ca11caf902
commit
bd0df49591
5 changed files with 87 additions and 53 deletions
|
|
@ -98,7 +98,7 @@ impl<'a, Sha1Impl: ISha1> FileOps<'a, Sha1Impl> {
|
|||
let mut file_iterator = self
|
||||
.files
|
||||
.iter()
|
||||
.zip(self.torrent.iter_filenames_and_lengths())
|
||||
.zip(self.torrent.iter_filenames_and_lengths()?)
|
||||
.enumerate()
|
||||
.map(|(idx, (fd, (name, len)))| {
|
||||
let full_file_required = if let Some(only_files) = only_files {
|
||||
|
|
@ -228,7 +228,7 @@ impl<'a, Sha1Impl: ISha1> FileOps<'a, Sha1Impl> {
|
|||
|
||||
let mut piece_remaining_bytes = piece_length as usize;
|
||||
|
||||
for (file_idx, (name, file_len)) in self.torrent.iter_filenames_and_lengths().enumerate() {
|
||||
for (file_idx, (name, file_len)) in self.torrent.iter_filenames_and_lengths()?.enumerate() {
|
||||
if absolute_offset > file_len {
|
||||
absolute_offset -= file_len;
|
||||
continue;
|
||||
|
|
@ -297,7 +297,7 @@ impl<'a, Sha1Impl: ISha1> FileOps<'a, Sha1Impl> {
|
|||
let mut absolute_offset = self.lengths.chunk_absolute_offset(&chunk_info);
|
||||
let mut buf = result_buf;
|
||||
|
||||
for (file_idx, file_len) in self.torrent.iter_file_lengths().enumerate() {
|
||||
for (file_idx, file_len) in self.torrent.iter_file_lengths()?.enumerate() {
|
||||
if absolute_offset > file_len {
|
||||
absolute_offset -= file_len;
|
||||
continue;
|
||||
|
|
@ -351,7 +351,7 @@ impl<'a, Sha1Impl: ISha1> FileOps<'a, Sha1Impl> {
|
|||
let mut buf = data.block.as_ref();
|
||||
let mut absolute_offset = self.lengths.chunk_absolute_offset(&chunk_info);
|
||||
|
||||
for (file_idx, (name, file_len)) in self.torrent.iter_filenames_and_lengths().enumerate() {
|
||||
for (file_idx, (name, file_len)) in self.torrent.iter_filenames_and_lengths()?.enumerate() {
|
||||
if absolute_offset > file_len {
|
||||
absolute_offset -= file_len;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ impl ApiInternal {
|
|||
.torrent_state()
|
||||
.info()
|
||||
.iter_filenames_and_lengths()
|
||||
.unwrap()
|
||||
.map(|(filename_it, length)| {
|
||||
let name = filename_it.to_string().ok();
|
||||
TorrentDetailsResponseFile { name, length }
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ struct TorrentManager {
|
|||
fn make_lengths<ByteBuf: AsRef<[u8]>>(
|
||||
torrent: &TorrentMetaV1Info<ByteBuf>,
|
||||
) -> anyhow::Result<Lengths> {
|
||||
let total_length = torrent.iter_file_lengths().sum();
|
||||
let total_length = torrent.iter_file_lengths()?.sum();
|
||||
Lengths::new(total_length, torrent.piece_length, None)
|
||||
}
|
||||
|
||||
|
|
@ -163,9 +163,9 @@ impl TorrentManager {
|
|||
let options = options.unwrap_or_default();
|
||||
let files = {
|
||||
let mut files =
|
||||
Vec::<Arc<Mutex<File>>>::with_capacity(info.iter_file_lengths().count());
|
||||
Vec::<Arc<Mutex<File>>>::with_capacity(info.iter_file_lengths()?.count());
|
||||
|
||||
for (path_bits, _) in info.iter_filenames_and_lengths() {
|
||||
for (path_bits, _) in info.iter_filenames_and_lengths()? {
|
||||
let mut full_path = out.as_ref().to_owned();
|
||||
for bit in path_bits.iter_components() {
|
||||
full_path.push(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue