« get me outta code hell

web-routes: make favicon route conditional on favicon - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-04-23 05:32:27 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-23 05:32:27 -0300
commitb7bd50af35487064bc7ee1fc0244c51ffdead002 (patch)
treef445271248b9f97f43cca7297ba624cd4a83d1da /src
parentfbfde5abbb2ac0c6c2d75eb1e6cbc324d92e402b (diff)
web-routes: make favicon route conditional on favicon
Diffstat (limited to 'src')
-rw-r--r--src/web-routes.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/web-routes.js b/src/web-routes.js
index a49f6d0e..b68dccbf 100644
--- a/src/web-routes.js
+++ b/src/web-routes.js
@@ -1,4 +1,4 @@
-import {readdir} from 'node:fs/promises';
+import {readdir, stat} from 'node:fs/promises';
 import * as path from 'node:path';
 import {fileURLToPath} from 'node:url';
 
@@ -103,17 +103,24 @@ export async function identifyDynamicWebRoutes({
         to: ['thumb.root'],
         statically: 'symlink',
       },
-
-      // {statically: 'copy'} is not workable for individual files
-      // at the moment, so this remains a symlink.
-      {
-        from: path.join(path.resolve(mediaPath), 'favicon.ico'),
-        to: ['shared.path', 'favicon.ico'],
-        statically: 'symlink',
-      },
     ]),
 
     () => {
+      const from =
+        path.resolve(path.join(mediaPath, 'favicon.ico'));
+
+      return stat(from).then(
+        // {statically: 'copy'} is not workable for individual files
+        // at the moment, so this remains a symlink.
+        () => [{
+          from,
+          to: ['shared.path', 'favicon.ico'],
+          statically: 'symlink',
+        }],
+        () => []);
+    },
+
+    () => {
       if (!wikiCachePath) return [];
 
       const from =