From 784600d930798a12080d7d22f24bfc2e1605ea7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 6 Apr 2021 18:22:59 -0400 Subject: [PATCH] fix: #9462, on install copy default favicon --- src/install.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/install.js b/src/install.js index f06c5cc6f0..10eb9a93ce 100644 --- a/src/install.js +++ b/src/install.js @@ -464,6 +464,22 @@ async function setCopyrightWidget() { } } +async function copyFavicon() { + const file = require('./file'); + const pathToIco = path.join(nconf.get('upload_path'), 'system', 'favicon.ico'); + const defaultIco = path.join(nconf.get('base_dir'), 'public', 'favicon.ico'); + const targetExists = await file.exists(pathToIco); + const defaultExists = await file.exists(defaultIco); + + if (defaultExists && !targetExists) { + try { + await fs.promises.copyFile(defaultIco, pathToIco); + } catch (err) { + winston.error(`Cannot copy favicon.ico\n${err.stack}`); + } + } +} + async function checkUpgrade() { const upgrade = require('./upgrade'); try { @@ -492,6 +508,7 @@ install.setup = async function () { await createWelcomePost(); await enableDefaultPlugins(); await setCopyrightWidget(); + await copyFavicon(); await checkUpgrade(); const data = {