mirror of
https://github.com/VERT-sh/VERT.git
synced 2025-12-16 22:25:22 -06:00
feat: add disabling temp video blocking (#206)
fixes #206. allows disabling temporarily blocking a file from being converted if repeated failures in an hour. especially useful for local deployments over a network where it may be served through HTTP rather than HTTPS, breaking video conversion due to the hashing code requiring a secure context.
This commit is contained in:
@@ -15,6 +15,11 @@ PUB_VERTD_URL=https://vertd.vert.sh
|
||||
# Note: the ffmpeg worker is still downloaded via a CDN (cdn.jsdelivr.net)
|
||||
PUB_DISABLE_ALL_EXTERNAL_REQUESTS=false
|
||||
|
||||
# Set to true to disable blocking video conversions of an uploaded file when repeated failures
|
||||
# occur within an hour. Useful for local deployments where secure context (HTTPS) may not be
|
||||
# available - required for calculating file hashes of videos to block temporarily.
|
||||
PUB_DISABLE_FAILURE_BLOCKS=false
|
||||
|
||||
# Stripe donation settings
|
||||
# Please keep these values the same, they support VERT's development!
|
||||
PUB_DONATION_URL=https://donations.vert.sh
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Settings } from "$lib/sections/settings/index.svelte";
|
||||
import { VertdInstance } from "$lib/sections/settings/vertdSettings.svelte";
|
||||
import { VertFile } from "$lib/types";
|
||||
import { Converter, FormatInfo } from "./converter.svelte";
|
||||
import { PUB_DISABLE_FAILURE_BLOCKS } from "$env/static/public";
|
||||
|
||||
interface UploadResponse {
|
||||
id: string;
|
||||
@@ -321,15 +322,18 @@ export class VertdConverter extends Converter {
|
||||
public async convert(input: VertFile, to: string): Promise<VertFile> {
|
||||
if (to.startsWith(".")) to = to.slice(1);
|
||||
|
||||
const hash = await input.hash();
|
||||
let hash: string;
|
||||
if (PUB_DISABLE_FAILURE_BLOCKS === "false") {
|
||||
hash = await input.hash();
|
||||
|
||||
if (this.blocked(hash)) {
|
||||
this.log(`conversion blocked for file ${input.name}`);
|
||||
throw new Error(
|
||||
m["convert.errors.vertd_ratelimit"]({
|
||||
filename: input.name,
|
||||
}),
|
||||
);
|
||||
if (this.blocked(hash)) {
|
||||
this.log(`conversion blocked for file ${input.name}`);
|
||||
throw new Error(
|
||||
m["convert.errors.vertd_ratelimit"]({
|
||||
filename: input.name,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const uploadRes = await uploadFile(input);
|
||||
@@ -403,7 +407,7 @@ export class VertdConverter extends Converter {
|
||||
case "error": {
|
||||
this.log(`error: ${msg.data.message}`);
|
||||
this.activeConversions.delete(input.id);
|
||||
this.failure(hash);
|
||||
if (hash) this.failure(hash);
|
||||
|
||||
reject({
|
||||
component: VertdErrorComponent,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import { VertdInstance } from "$lib/sections/settings/vertdSettings.svelte.js";
|
||||
import { ToastManager } from "$lib/util/toast.svelte.js";
|
||||
import { m } from "$lib/paraglide/messages.js";
|
||||
import { log } from "$lib/util/logger.js";
|
||||
|
||||
let { children, data } = $props();
|
||||
let enablePlausible = $state(false);
|
||||
@@ -96,6 +97,7 @@
|
||||
|
||||
// detect if insecure context
|
||||
if (!window.isSecureContext) {
|
||||
log(["layout"], "Insecure context (HTTP) detected, some features may not work as expected -- you may want to enable \"PUB_DISABLE_FAILURE_BLOCKS\" on local deployments.");
|
||||
ToastManager.add({
|
||||
type: "warning",
|
||||
message: m["toast.insecure_context"](),
|
||||
|
||||
Reference in New Issue
Block a user