Merge branch 'feat_wait_for_upload' into 'master'

Feat wait for upload

See merge request veretcle/scootaloo!54
This commit is contained in:
VC
2023-02-09 14:51:14 +00:00
3 changed files with 4 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -1316,7 +1316,7 @@ dependencies = [
[[package]] [[package]]
name = "scootaloo" name = "scootaloo"
version = "1.1.5" version = "1.1.6"
dependencies = [ dependencies = [
"base64", "base64",
"clap", "clap",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "scootaloo" name = "scootaloo"
version = "1.1.5" version = "1.1.6"
authors = ["VC <veretcle+framagit@mateu.be>"] authors = ["VC <veretcle+framagit@mateu.be>"]
edition = "2021" edition = "2021"

View File

@@ -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),