mirror of
https://github.com/v0l/route96.git
synced 2025-06-22 13:38:07 +00:00
chore: add logging non-200 response in mirror
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -3,7 +3,7 @@ use crate::db::{Database, FileUpload};
|
|||||||
use crate::filesystem::{FileStore, FileSystemResult};
|
use crate::filesystem::{FileStore, FileSystemResult};
|
||||||
use crate::routes::{delete_file, Nip94Event};
|
use crate::routes::{delete_file, Nip94Event};
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use log::error;
|
use log::{error, info};
|
||||||
use nostr::prelude::hex;
|
use nostr::prelude::hex;
|
||||||
use nostr::{Alphabet, JsonUtil, SingleLetterTag, TagKind};
|
use nostr::{Alphabet, JsonUtil, SingleLetterTag, TagKind};
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
@ -249,12 +249,23 @@ async fn mirror(
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
info!("Requesting mirror: {}", url);
|
||||||
// download file
|
// download file
|
||||||
let rsp = match client.get(url.clone()).send().await {
|
let rsp = match client.get(url.clone()).send().await {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Error downloading file: {}", e);
|
error!("Error downloading file: {}", e);
|
||||||
return BlossomResponse::error("Failed to mirror file");
|
return BlossomResponse::error("Failed to mirror file");
|
||||||
}
|
}
|
||||||
|
Ok(rsp) if !rsp.status().is_success() => {
|
||||||
|
let status = rsp.status();
|
||||||
|
let body = rsp.bytes().await.unwrap_or(Default::default());
|
||||||
|
error!(
|
||||||
|
"Error downloading file, status is not OK({}): {}",
|
||||||
|
status,
|
||||||
|
String::from_utf8_lossy(&body)
|
||||||
|
);
|
||||||
|
return BlossomResponse::error("Failed to mirror file");
|
||||||
|
}
|
||||||
Ok(rsp) => rsp,
|
Ok(rsp) => rsp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user