X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fdingus.js;h=0a5f9d8d50badb5dc0ceb3b4a3c4d876a87cc58e;hb=97be4c0841f2615651c6cd6fb466aada47773cc4;hp=9bc428282b94c3f187563266377a370c65b38ccf;hpb=031c170bdaf1d9c331e6f6fc701ce6540c0e6941;p=squeep-api-dingus diff --git a/lib/dingus.js b/lib/dingus.js index 9bc4282..0a5f9d8 100644 --- a/lib/dingus.js +++ b/lib/dingus.js @@ -19,7 +19,8 @@ const Router = require('./router'); const Template = require('./template'); // For logging. -const _fileScope = common.fileScope(__filename); +const { fileScope } = require('@squeep/log-helper'); +const _fileScope = fileScope(__filename); const defaultOptions = { ignoreTrailingSlash: true, @@ -519,8 +520,8 @@ class Dingus { */ async _serveFileMetaHeaders(res, directory, fileName) { const _scope = _fileScope('_serveFileMetaHeaders'); - this.logger.debug(_scope, 'called', { directory, fileName }); + let added = false; const metaPrefix = '.'; const metaSuffix = '.meta'; const metaFileName = `${metaPrefix}${fileName}${metaSuffix}`; @@ -528,7 +529,7 @@ class Dingus { const [stat, data] = await this._readFileInfo(metaFilePath); if (!stat) { - return; + return added; } const lineBreakRE = /\r\n|\n|\r/; @@ -541,8 +542,10 @@ class Dingus { const result = headerParseRE.exec(line); const { groups: header } = result; res.setHeader(header.name, header.value); + added = true; } }); + return added; } @@ -635,7 +638,7 @@ class Dingus { res.setHeader(Enum.Header.CacheControl, 'public'); if (this.staticMetadata) { - await this._serveFileMetaHeaders(res, directory, fileName); + ctx.metaHeaders = await this._serveFileMetaHeaders(res, directory, fileName); } this.logger.debug(_scope, 'serving file', { filePath, contentType });