Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check if media downloadable #219

Merged
merged 2 commits into from
Feb 3, 2024
Merged

Conversation

IMXEren
Copy link
Contributor

@IMXEren IMXEren commented Feb 3, 2024

Aims to fix #216 . Tested with code:

// If there's a error, propagates it back to the caller.
let download = message.download_media(&path).await?;

// OR

if let Ok(to_download) = message.download_media(&path).await {
    if to_download {
        // Media was there to download
    }
}

// OR

let download = message.download_media(&path).await;
if download.is_ok() && download.unwrap() {
    // Media was there to download
}

I suppose that there is no need to change the description for client.download_media(). Users must implement error handling and not call .unwrap() directly.

@Lonami Lonami merged commit 8a72095 into Lonami:master Feb 3, 2024
1 check passed
@Lonami
Copy link
Owner

Lonami commented Feb 3, 2024

Thanks.

@IMXEren IMXEren deleted the download-media-unwrap branch February 18, 2024 09:43
IMXEren added a commit to IMXEren/grammers that referenced this pull request Feb 18, 2024
* Avoid panic when media is not downloadable (Lonami#219)

* Fix factorize could return 1

Closes Lonami#220.

* Make factorize function more resiliant

* Bump grammers-crypto to 0.6

* Fix other packages must use latest -crypto

---------

Co-authored-by: Lonami Exo <totufals@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thread panicking when calling message.download_media()
2 participants