From b7bd50af35487064bc7ee1fc0244c51ffdead002 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 23 Apr 2025 05:32:27 -0300 Subject: web-routes: make favicon route conditional on favicon --- src/web-routes.js | 25 ++++++++++++++++--------- 1 file 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,16 +103,23 @@ 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 []; -- cgit 1.3.0-6-gf8a5