mirror of
https://github.com/flibusta-apps/telegram_files_cache_server.git
synced 2025-12-06 14:45:36 +01:00
Fix
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
use reqwest::Response;
|
use std::fmt;
|
||||||
|
|
||||||
|
use reqwest::{Response, StatusCode};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
@@ -11,6 +13,20 @@ pub struct FilenameData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
struct DownloadError {
|
||||||
|
status_code: StatusCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for DownloadError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Status code is {0}", self.status_code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for DownloadError {}
|
||||||
|
|
||||||
|
|
||||||
pub async fn download_from_downloader(
|
pub async fn download_from_downloader(
|
||||||
remote_id: u32,
|
remote_id: u32,
|
||||||
object_id: i32,
|
object_id: i32,
|
||||||
@@ -28,6 +44,10 @@ pub async fn download_from_downloader(
|
|||||||
.await?
|
.await?
|
||||||
.error_for_status()?;
|
.error_for_status()?;
|
||||||
|
|
||||||
|
if response.status() == StatusCode::NO_CONTENT {
|
||||||
|
return Err(Box::new(DownloadError { status_code: StatusCode::NO_CONTENT }))
|
||||||
|
};
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use std::fmt;
|
use reqwest::{Response, multipart::{Form, Part}, header};
|
||||||
|
|
||||||
use reqwest::{Response, multipart::{Form, Part}, header, StatusCode};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tracing::log;
|
use tracing::log;
|
||||||
|
|
||||||
@@ -21,19 +19,6 @@ pub struct UploadResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct DownloadError {
|
|
||||||
status_code: StatusCode,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for DownloadError {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "Status code is {0}", self.status_code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::error::Error for DownloadError {}
|
|
||||||
|
|
||||||
pub async fn download_from_telegram_files(
|
pub async fn download_from_telegram_files(
|
||||||
message_id: i64,
|
message_id: i64,
|
||||||
chat_id: i64
|
chat_id: i64
|
||||||
@@ -50,10 +35,6 @@ pub async fn download_from_telegram_files(
|
|||||||
.await?
|
.await?
|
||||||
.error_for_status()?;
|
.error_for_status()?;
|
||||||
|
|
||||||
if response.status() == StatusCode::NO_CONTENT {
|
|
||||||
return Err(Box::new(DownloadError { status_code: StatusCode::NO_CONTENT }))
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user