From d446dfd87e5c5974491f570ac64fa6ec020a20ca Mon Sep 17 00:00:00 2001
From: dumbmoron <log@riseup.net>
Date: Sat, 17 Aug 2024 13:26:10 +0000
Subject: [PATCH] web/remux: correctly unset processing state

---
 web/src/routes/remux/+page.svelte | 67 ++++++++++++++++---------------
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/web/src/routes/remux/+page.svelte b/web/src/routes/remux/+page.svelte
index 3229e863..2570f132 100644
--- a/web/src/routes/remux/+page.svelte
+++ b/web/src/routes/remux/+page.svelte
@@ -43,43 +43,44 @@
     const render = async () => {
         if (!file || processing) return;
         await ff.init();
+        try {
+            progress = '';
+            processing = true;
 
-        progress = '';
-        processing = true;
+            const file_info = await ff.probe(file);
+            if (!file_info?.format) {
+                return createDialog({
+                    id: "remux-error",
+                    type: "small",
+                    meowbalt: "error",
+                    bodyText: $t("error.remux.corrupted"),
+                    buttons: [
+                        {
+                            text: $t("button.gotit"),
+                            main: true,
+                            action: () => {},
+                        },
+                    ],
+                });
+            }
 
-        const file_info = await ff.probe(file);
-        if (!file_info?.format) {
-            return createDialog({
-                id: "remux-error",
-                type: "small",
-                meowbalt: "error",
-                bodyText: $t("error.remux.corrupted"),
-                buttons: [
-                    {
-                        text: $t("button.gotit"),
-                        main: true,
-                        action: () => {},
-                    },
-                ],
+            totalDuration = Number(file_info.format.duration);
+
+            const render = await ff.render({
+                blob: file,
+                args: ['-c', 'copy', '-map', '0']
             });
+
+            if (render) {
+                openURL(URL.createObjectURL(render));
+            } else {
+                console.log("not a valid file");
+            }
+
+        } finally {
+            processing = false;
+            file = undefined;
         }
-
-        totalDuration = Number(file_info.format.duration);
-
-        const render = await ff.render({
-            blob: file,
-            args: ['-c', 'copy', '-map', '0']
-        });
-
-        processing = false;
-
-        if (render) {
-            openURL(URL.createObjectURL(render));
-        } else {
-            console.log("not a valid file");
-        }
-
-        file = undefined;
     };
 
     $: if (file) {