Skip to content

Commit

Permalink
used try next instead of next
Browse files Browse the repository at this point in the history
  • Loading branch information
YouKnow-sys committed Dec 20, 2024
1 parent c2c658f commit 366e457
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/grammers-client/src/client/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::future::Future;
use std::task::Poll;
use std::{io::SeekFrom, path::Path, sync::Arc};

use futures::Stream;
use futures::{Stream, TryStreamExt};
use futures_util::stream::{FuturesUnordered, StreamExt};
use tokio::sync::mpsc::unbounded_channel;
use tokio::{
Expand Down Expand Up @@ -259,8 +259,11 @@ impl Client {

async fn load<P: AsRef<Path>>(path: P, download: &mut DownloadStream) -> Result<(), io::Error> {
let mut file = fs::File::create(path).await?;
while let Some(res) = download.next().await {
let chunk = res.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
while let Some(chunk) = download
.try_next()
.await
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?
{
file.write_all(&chunk).await?;
}

Expand Down

0 comments on commit 366e457

Please sign in to comment.