mirror of
https://github.com/v0l/route96.git
synced 2025-06-14 15:46:32 +00:00
Compare commits
5 Commits
ec271f4109
...
main
Author | SHA1 | Date | |
---|---|---|---|
b6c12de685
|
|||
470af79a24
|
|||
5048c4104a
|
|||
6b6e0d4dec
|
|||
2576f75bc4
|
18
.drone.yml
18
.drone.yml
@ -5,17 +5,24 @@ metadata:
|
||||
namespace: git
|
||||
concurrency:
|
||||
limit: 1
|
||||
volumes:
|
||||
- name: cache
|
||||
claim:
|
||||
name: storage2
|
||||
steps:
|
||||
- name: build
|
||||
image: docker
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: cache
|
||||
path: /cache
|
||||
environment:
|
||||
TOKEN:
|
||||
from_secret: gitea
|
||||
TOKEN_DOCKER:
|
||||
from_secret: docker_hub
|
||||
commands:
|
||||
- dockerd &
|
||||
- dockerd --data-root /cache/dockerd &
|
||||
- docker login -u voidic -p $TOKEN_DOCKER
|
||||
- docker buildx build --push -t voidic/route96:latest .
|
||||
- kill $(cat /var/run/docker.pid)
|
||||
@ -30,17 +37,24 @@ trigger:
|
||||
- tag
|
||||
metadata:
|
||||
namespace: git
|
||||
volumes:
|
||||
- name: cache
|
||||
claim:
|
||||
name: storage2
|
||||
steps:
|
||||
- name: build
|
||||
image: docker
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: cache
|
||||
path: /cache
|
||||
environment:
|
||||
TOKEN:
|
||||
from_secret: gitea
|
||||
TOKEN_DOCKER:
|
||||
from_secret: docker_hub
|
||||
commands:
|
||||
- dockerd &
|
||||
- dockerd --data-root /cache/dockerd &
|
||||
- docker login -u voidic -p $TOKEN_DOCKER
|
||||
- docker buildx build --push voidic/route96:$DRONE_TAG .
|
||||
- kill $(cat /var/run/docker.pid)
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -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",
|
||||
|
@ -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 }
|
||||
|
@ -12,6 +12,7 @@ RUN apt update && \
|
||||
apt install -y \
|
||||
build-essential \
|
||||
libx264-dev \
|
||||
libx265-dev \
|
||||
libwebp-dev \
|
||||
libvpx-dev \
|
||||
nasm \
|
||||
@ -27,6 +28,7 @@ RUN git clone --single-branch --branch release/7.1 https://git.v0l.io/ffmpeg/FFm
|
||||
--disable-network \
|
||||
--enable-gpl \
|
||||
--enable-libx264 \
|
||||
--enable-libx265 \
|
||||
--enable-libwebp \
|
||||
--enable-libvpx \
|
||||
--disable-static \
|
||||
|
@ -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() {
|
||||
|
@ -364,13 +364,10 @@ async fn process_upload(
|
||||
return e;
|
||||
}
|
||||
|
||||
// check quota
|
||||
// check quota (only if payments are configured)
|
||||
#[cfg(feature = "payments")]
|
||||
{
|
||||
let free_quota = settings
|
||||
.payments
|
||||
.as_ref()
|
||||
.and_then(|p| p.free_quota_bytes)
|
||||
if let Some(payment_config) = &settings.payments {
|
||||
let free_quota = payment_config.free_quota_bytes
|
||||
.unwrap_or(104857600); // Default to 100MB
|
||||
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
||||
|
||||
@ -442,31 +439,30 @@ where
|
||||
}
|
||||
};
|
||||
|
||||
// Post-upload quota check if we didn't have size information before upload
|
||||
// Post-upload quota check if we didn't have size information before upload (only if payments are configured)
|
||||
#[cfg(feature = "payments")]
|
||||
if size == 0 {
|
||||
let free_quota = settings
|
||||
.payments
|
||||
.as_ref()
|
||||
.and_then(|p| p.free_quota_bytes)
|
||||
.unwrap_or(104857600); // Default to 100MB
|
||||
|
||||
match db.check_user_quota(pubkey, upload.size, free_quota).await {
|
||||
Ok(false) => {
|
||||
// Clean up the uploaded file if quota exceeded
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup quota-exceeding file: {}", e);
|
||||
if let Some(payment_config) = &settings.payments {
|
||||
let free_quota = payment_config.free_quota_bytes
|
||||
.unwrap_or(104857600); // Default to 100MB
|
||||
|
||||
match db.check_user_quota(pubkey, upload.size, free_quota).await {
|
||||
Ok(false) => {
|
||||
// Clean up the uploaded file if quota exceeded
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup quota-exceeding file: {}", e);
|
||||
}
|
||||
return BlossomResponse::error("Upload would exceed quota");
|
||||
}
|
||||
return BlossomResponse::error("Upload would exceed quota");
|
||||
}
|
||||
Err(_) => {
|
||||
// Clean up on quota check error
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup file after quota check error: {}", e);
|
||||
Err(_) => {
|
||||
// Clean up on quota check error
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup file after quota check error: {}", e);
|
||||
}
|
||||
return BlossomResponse::error("Failed to check quota");
|
||||
}
|
||||
return BlossomResponse::error("Failed to check quota");
|
||||
Ok(true) => {} // Quota check passed
|
||||
}
|
||||
Ok(true) => {} // Quota check passed
|
||||
}
|
||||
}
|
||||
if let Err(e) = db.add_file(&upload, user_id).await {
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
@ -205,11 +205,10 @@ async fn upload(
|
||||
|
||||
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
||||
|
||||
// check quota
|
||||
// check quota (only if payments are configured)
|
||||
#[cfg(feature = "payments")]
|
||||
{
|
||||
let free_quota = settings.payments.as_ref()
|
||||
.and_then(|p| p.free_quota_bytes)
|
||||
if let Some(payment_config) = &settings.payments {
|
||||
let free_quota = payment_config.free_quota_bytes
|
||||
.unwrap_or(104857600); // Default to 100MB
|
||||
|
||||
if upload_size > 0 {
|
||||
@ -255,29 +254,30 @@ async fn upload(
|
||||
Err(e) => return Nip96Response::error(&format!("Could not save user: {}", e)),
|
||||
};
|
||||
|
||||
// Post-upload quota check if we didn't have size information before upload
|
||||
// Post-upload quota check if we didn't have size information before upload (only if payments are configured)
|
||||
#[cfg(feature = "payments")]
|
||||
if upload_size == 0 {
|
||||
let free_quota = settings.payments.as_ref()
|
||||
.and_then(|p| p.free_quota_bytes)
|
||||
.unwrap_or(104857600); // Default to 100MB
|
||||
|
||||
match db.check_user_quota(&pubkey_vec, upload.size, free_quota).await {
|
||||
Ok(false) => {
|
||||
// Clean up the uploaded file if quota exceeded
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup quota-exceeding file: {}", e);
|
||||
if let Some(payment_config) = &settings.payments {
|
||||
let free_quota = payment_config.free_quota_bytes
|
||||
.unwrap_or(104857600); // Default to 100MB
|
||||
|
||||
match db.check_user_quota(&pubkey_vec, upload.size, free_quota).await {
|
||||
Ok(false) => {
|
||||
// Clean up the uploaded file if quota exceeded
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup quota-exceeding file: {}", e);
|
||||
}
|
||||
return Nip96Response::error("Upload would exceed quota");
|
||||
}
|
||||
return Nip96Response::error("Upload would exceed quota");
|
||||
}
|
||||
Err(_) => {
|
||||
// Clean up on quota check error
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup file after quota check error: {}", e);
|
||||
Err(_) => {
|
||||
// Clean up on quota check error
|
||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||
log::warn!("Failed to cleanup file after quota check error: {}", e);
|
||||
}
|
||||
return Nip96Response::error("Failed to check quota");
|
||||
}
|
||||
return Nip96Response::error("Failed to check quota");
|
||||
Ok(true) => {} // Quota check passed
|
||||
}
|
||||
Ok(true) => {} // Quota check passed
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user