mirror of
https://github.com/v0l/route96.git
synced 2025-06-14 23:46:34 +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
|
namespace: git
|
||||||
concurrency:
|
concurrency:
|
||||||
limit: 1
|
limit: 1
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
claim:
|
||||||
|
name: storage2
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: docker
|
image: docker
|
||||||
privileged: true
|
privileged: true
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
path: /cache
|
||||||
environment:
|
environment:
|
||||||
TOKEN:
|
TOKEN:
|
||||||
from_secret: gitea
|
from_secret: gitea
|
||||||
TOKEN_DOCKER:
|
TOKEN_DOCKER:
|
||||||
from_secret: docker_hub
|
from_secret: docker_hub
|
||||||
commands:
|
commands:
|
||||||
- dockerd &
|
- dockerd --data-root /cache/dockerd &
|
||||||
- docker login -u voidic -p $TOKEN_DOCKER
|
- docker login -u voidic -p $TOKEN_DOCKER
|
||||||
- docker buildx build --push -t voidic/route96:latest .
|
- docker buildx build --push -t voidic/route96:latest .
|
||||||
- kill $(cat /var/run/docker.pid)
|
- kill $(cat /var/run/docker.pid)
|
||||||
@ -30,17 +37,24 @@ trigger:
|
|||||||
- tag
|
- tag
|
||||||
metadata:
|
metadata:
|
||||||
namespace: git
|
namespace: git
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
claim:
|
||||||
|
name: storage2
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: docker
|
image: docker
|
||||||
privileged: true
|
privileged: true
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
path: /cache
|
||||||
environment:
|
environment:
|
||||||
TOKEN:
|
TOKEN:
|
||||||
from_secret: gitea
|
from_secret: gitea
|
||||||
TOKEN_DOCKER:
|
TOKEN_DOCKER:
|
||||||
from_secret: docker_hub
|
from_secret: docker_hub
|
||||||
commands:
|
commands:
|
||||||
- dockerd &
|
- dockerd --data-root /cache/dockerd &
|
||||||
- docker login -u voidic -p $TOKEN_DOCKER
|
- docker login -u voidic -p $TOKEN_DOCKER
|
||||||
- docker buildx build --push voidic/route96:$DRONE_TAG .
|
- docker buildx build --push voidic/route96:$DRONE_TAG .
|
||||||
- kill $(cat /var/run/docker.pid)
|
- kill $(cat /var/run/docker.pid)
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1070,7 +1070,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ffmpeg-rs-raw"
|
name = "ffmpeg-rs-raw"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"ffmpeg-sys-the-third",
|
"ffmpeg-sys-the-third",
|
||||||
|
@ -44,7 +44,7 @@ http-range-header = { version = "0.4.2" }
|
|||||||
base58 = "0.2.0"
|
base58 = "0.2.0"
|
||||||
|
|
||||||
libc = { version = "0.2.153", optional = true }
|
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-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-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 }
|
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 \
|
apt install -y \
|
||||||
build-essential \
|
build-essential \
|
||||||
libx264-dev \
|
libx264-dev \
|
||||||
|
libx265-dev \
|
||||||
libwebp-dev \
|
libwebp-dev \
|
||||||
libvpx-dev \
|
libvpx-dev \
|
||||||
nasm \
|
nasm \
|
||||||
@ -27,6 +28,7 @@ RUN git clone --single-branch --branch release/7.1 https://git.v0l.io/ffmpeg/FFm
|
|||||||
--disable-network \
|
--disable-network \
|
||||||
--enable-gpl \
|
--enable-gpl \
|
||||||
--enable-libx264 \
|
--enable-libx264 \
|
||||||
|
--enable-libx265 \
|
||||||
--enable-libwebp \
|
--enable-libwebp \
|
||||||
--enable-libvpx \
|
--enable-libvpx \
|
||||||
--disable-static \
|
--disable-static \
|
||||||
|
@ -105,7 +105,12 @@ impl WebpProcessor {
|
|||||||
let mut decoder = Decoder::new();
|
let mut decoder = Decoder::new();
|
||||||
decoder.setup_decoder(image_stream, None)?;
|
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();
|
let mut frame_save: *mut AVFrame = ptr::null_mut();
|
||||||
for (mut frame, _stream) in decoder.decode_pkt(pkt)? {
|
for (mut frame, _stream) in decoder.decode_pkt(pkt)? {
|
||||||
if frame_save.is_null() {
|
if frame_save.is_null() {
|
||||||
|
@ -364,13 +364,10 @@ async fn process_upload(
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check quota
|
// check quota (only if payments are configured)
|
||||||
#[cfg(feature = "payments")]
|
#[cfg(feature = "payments")]
|
||||||
{
|
if let Some(payment_config) = &settings.payments {
|
||||||
let free_quota = settings
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.payments
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|p| p.free_quota_bytes)
|
|
||||||
.unwrap_or(104857600); // Default to 100MB
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
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")]
|
#[cfg(feature = "payments")]
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
let free_quota = settings
|
if let Some(payment_config) = &settings.payments {
|
||||||
.payments
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.as_ref()
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
.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) => {
|
||||||
match db.check_user_quota(pubkey, upload.size, free_quota).await {
|
// Clean up the uploaded file if quota exceeded
|
||||||
Ok(false) => {
|
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||||
// Clean up the uploaded file if quota exceeded
|
log::warn!("Failed to cleanup quota-exceeding file: {}", e);
|
||||||
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
|
||||||
Err(_) => {
|
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||||
// Clean up on quota check error
|
log::warn!("Failed to cleanup file after quota check error: {}", e);
|
||||||
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 {
|
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() {
|
if !thumb_file.exists() {
|
||||||
let mut p = WebpProcessor::new();
|
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);
|
return Err(Status::InternalServerError);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -205,11 +205,10 @@ async fn upload(
|
|||||||
|
|
||||||
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
let pubkey_vec = auth.event.pubkey.to_bytes().to_vec();
|
||||||
|
|
||||||
// check quota
|
// check quota (only if payments are configured)
|
||||||
#[cfg(feature = "payments")]
|
#[cfg(feature = "payments")]
|
||||||
{
|
if let Some(payment_config) = &settings.payments {
|
||||||
let free_quota = settings.payments.as_ref()
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.and_then(|p| p.free_quota_bytes)
|
|
||||||
.unwrap_or(104857600); // Default to 100MB
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
|
|
||||||
if upload_size > 0 {
|
if upload_size > 0 {
|
||||||
@ -255,29 +254,30 @@ async fn upload(
|
|||||||
Err(e) => return Nip96Response::error(&format!("Could not save user: {}", e)),
|
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")]
|
#[cfg(feature = "payments")]
|
||||||
if upload_size == 0 {
|
if upload_size == 0 {
|
||||||
let free_quota = settings.payments.as_ref()
|
if let Some(payment_config) = &settings.payments {
|
||||||
.and_then(|p| p.free_quota_bytes)
|
let free_quota = payment_config.free_quota_bytes
|
||||||
.unwrap_or(104857600); // Default to 100MB
|
.unwrap_or(104857600); // Default to 100MB
|
||||||
|
|
||||||
match db.check_user_quota(&pubkey_vec, upload.size, free_quota).await {
|
match db.check_user_quota(&pubkey_vec, upload.size, free_quota).await {
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
// Clean up the uploaded file if quota exceeded
|
// Clean up the uploaded file if quota exceeded
|
||||||
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||||
log::warn!("Failed to cleanup quota-exceeding file: {}", e);
|
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
|
||||||
Err(_) => {
|
if let Err(e) = tokio::fs::remove_file(fs.get(&upload.id)).await {
|
||||||
// Clean up on quota check error
|
log::warn!("Failed to cleanup file after quota check error: {}", e);
|
||||||
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