mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
feat: wait 1 full sec between loop when uploading big media
This commit is contained in:
@@ -15,6 +15,7 @@ use std::error::Error;
|
|||||||
use tokio::{
|
use tokio::{
|
||||||
fs::{create_dir_all, remove_file, File},
|
fs::{create_dir_all, remove_file, File},
|
||||||
io::copy,
|
io::copy,
|
||||||
|
time::{sleep, Duration},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Generate associative table between media ids and tweet extended entities
|
/// Generate associative table between media ids and tweet extended entities
|
||||||
@@ -85,6 +86,7 @@ pub async fn generate_media_ids(
|
|||||||
/// Wait on uploaded medias when necessary
|
/// Wait on uploaded medias when necessary
|
||||||
async fn wait_until_uploaded(client: &Mastodon, id: &str) -> Result<String, error::Error> {
|
async fn wait_until_uploaded(client: &Mastodon, id: &str) -> Result<String, error::Error> {
|
||||||
loop {
|
loop {
|
||||||
|
sleep(Duration::from_secs(1)).await;
|
||||||
let res = client.get_media(id.to_string()).await;
|
let res = client.get_media(id.to_string()).await;
|
||||||
return match res {
|
return match res {
|
||||||
Ok(res) => Ok(res.json.id),
|
Ok(res) => Ok(res.json.id),
|
||||||
|
Reference in New Issue
Block a user