Skip to content

armgit / VERT

Public Imported from GitHub
0

The next-generation file converter. Open source, fully local* and free forever.

feat: add disabling temp video blocking (#206)

Maya0cc13f6a76de
diff --git a/.env.example b/.env.example
index 3ed0ff6..898e99a 100644
--- a/.env.example
+++ b/.env.example
@@ -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
diff --git a/src/lib/converters/vertd.svelte.ts b/src/lib/converters/vertd.svelte.ts
index a21d2e5..0c41efe 100644
--- a/src/lib/converters/vertd.svelte.ts
+++ b/src/lib/converters/vertd.svelte.ts
@@ -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,
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index fc10d66..5b6e669 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -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"](),