mirror of
https://github.com/v0l/route96.git
synced 2025-06-14 23:46:34 +00:00
Compare commits
2 Commits
6b6e0d4dec
...
470af79a24
Author | SHA1 | Date | |
---|---|---|---|
470af79a24
|
|||
5048c4104a
|
@ -12,13 +12,14 @@ 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 \
|
||||||
libclang-dev \
|
libclang-dev \
|
||||||
protobuf-compiler && \
|
protobuf-compiler && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
RUN git clone --single-branch --branch master https://git.v0l.io/ffmpeg/FFmpeg.git && \
|
RUN git clone --single-branch --branch release/7.1 https://git.v0l.io/ffmpeg/FFmpeg.git && \
|
||||||
cd FFmpeg && \
|
cd FFmpeg && \
|
||||||
./configure \
|
./configure \
|
||||||
--prefix=${FFMPEG_DIR} \
|
--prefix=${FFMPEG_DIR} \
|
||||||
@ -27,6 +28,7 @@ RUN git clone --single-branch --branch master https://git.v0l.io/ffmpeg/FFmpeg.g
|
|||||||
--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 \
|
||||||
|
@ -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 {
|
||||||
|
@ -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