Compare commits

...

2 Commits

Author SHA1 Message Date
455970b9fe fix: mime like
Some checks reported errors
continuous-integration/drone Build was killed
continuous-integration/drone/push Build is passing
2025-06-17 11:56:00 +01:00
b6c12de685 fix: decoder bug
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-11 23:58:44 +01:00
5 changed files with 28 additions and 11 deletions

2
Cargo.lock generated
View File

@ -1070,7 +1070,7 @@ dependencies = [
[[package]]
name = "ffmpeg-rs-raw"
version = "0.1.0"
source = "git+https://git.v0l.io/Kieran/ffmpeg-rs-raw.git?rev=928ab9664ff47c1b0bd8313ebc73d13b1ab43fc5#928ab9664ff47c1b0bd8313ebc73d13b1ab43fc5"
source = "git+https://git.v0l.io/Kieran/ffmpeg-rs-raw.git?rev=aa1ce3edcad0fcd286d39b3e0c2fdc610c3988e7#aa1ce3edcad0fcd286d39b3e0c2fdc610c3988e7"
dependencies = [
"anyhow",
"ffmpeg-sys-the-third",

View File

@ -44,7 +44,7 @@ http-range-header = { version = "0.4.2" }
base58 = "0.2.0"
libc = { version = "0.2.153", optional = true }
ffmpeg-rs-raw = { git = "https://git.v0l.io/Kieran/ffmpeg-rs-raw.git", rev = "928ab9664ff47c1b0bd8313ebc73d13b1ab43fc5", optional = true }
ffmpeg-rs-raw = { git = "https://git.v0l.io/Kieran/ffmpeg-rs-raw.git", rev = "aa1ce3edcad0fcd286d39b3e0c2fdc610c3988e7", optional = true }
candle-core = { git = "https://git.v0l.io/huggingface/candle.git", tag = "0.8.1", optional = true }
candle-nn = { git = "https://git.v0l.io/huggingface/candle.git", tag = "0.8.1", optional = true }
candle-transformers = { git = "https://git.v0l.io/huggingface/candle.git", tag = "0.8.1", optional = true }

View File

@ -105,7 +105,12 @@ impl WebpProcessor {
let mut decoder = Decoder::new();
decoder.setup_decoder(image_stream, None)?;
while let Ok((mut pkt, _stream)) = input.get_packet() {
while let Ok((mut pkt, _)) = input.get_packet() {
// skip packets not in the image stream
if (*pkt).stream_index != image_stream.index as i32 {
av_packet_free(&mut pkt);
continue;
}
let mut frame_save: *mut AVFrame = ptr::null_mut();
for (mut frame, _stream) in decoder.decode_pkt(pkt)? {
if frame_save.is_null() {

View File

@ -1,5 +1,5 @@
use crate::auth::nip98::Nip98Auth;
use crate::db::{Database, FileUpload, User, Report};
use crate::db::{Database, FileUpload, Report, User};
use crate::routes::{Nip94Event, PagedResult};
use crate::settings::Settings;
use rocket::serde::json::Json;
@ -8,7 +8,12 @@ use rocket::{routes, Responder, Route, State};
use sqlx::{Error, QueryBuilder, Row};
pub fn admin_routes() -> Vec<Route> {
routes![admin_list_files, admin_get_self, admin_list_reports, admin_acknowledge_report]
routes![
admin_list_files,
admin_get_self,
admin_list_reports,
admin_acknowledge_report
]
}
#[derive(Serialize, Default)]
@ -71,7 +76,11 @@ pub struct AdminNip94File {
}
#[rocket::get("/self")]
async fn admin_get_self(auth: Nip98Auth, db: &State<Database>, settings: &State<Settings>) -> AdminResponse<SelfUser> {
async fn admin_get_self(
auth: Nip98Auth,
db: &State<Database>,
settings: &State<Settings>,
) -> AdminResponse<SelfUser> {
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
match db.get_user(&pubkey_vec).await {
Ok(user) => {
@ -84,7 +93,9 @@ async fn admin_get_self(auth: Nip98Auth, db: &State<Database>, settings: &State<
#[cfg(feature = "payments")]
let (free_quota, total_available_quota) = {
let free_quota = settings.payments.as_ref()
let free_quota = settings
.payments
.as_ref()
.and_then(|p| p.free_quota_bytes)
.unwrap_or(104857600);
let mut total_available = free_quota;
@ -223,7 +234,7 @@ impl Database {
) -> Result<(Vec<(FileUpload, Vec<User>)>, i64), Error> {
let mut q = QueryBuilder::new("select u.* from uploads u ");
if let Some(m) = mime_type {
q.push("where u.mime_type = ");
q.push("where u.mime_type like ");
q.push_bind(m);
}
q.push(" order by u.created desc limit ");

View File

@ -423,7 +423,8 @@ pub async fn get_blob_thumb(
if !thumb_file.exists() {
let mut p = WebpProcessor::new();
if p.thumbnail(&file_path, &thumb_file).is_err() {
if let Err(e) = p.thumbnail(&file_path, &thumb_file) {
warn!("Failed to generate thumbnail: {}", e);
return Err(Status::InternalServerError);
}
};