Browse Source

fix: pageHelper getFileExtension missing return

pull/1134/head
NGPixel 5 years ago
parent
commit
f4816d0628
3 changed files with 10 additions and 9 deletions
  1. 2
      server/helpers/page.js
  2. 9
      server/modules/storage/disk/storage.js
  3. 8
      server/modules/storage/git/storage.js

2
server/helpers/page.js

@ -101,7 +101,7 @@ module.exports = {
* Get file extension from content type * Get file extension from content type
*/ */
getFileExtension(contentType) { getFileExtension(contentType) {
_.get(contentToExt, contentType, 'txt')
return _.get(contentToExt, contentType, 'txt')
}, },
/** /**
* Get content type from file extension * Get content type from file extension

9
server/modules/storage/disk/storage.js

@ -45,7 +45,7 @@ module.exports = {
} }
}, },
async created(page) { async created(page) {
WIKI.logger.info(`(STORAGE/DISK) Creating file ${page.path}...`)
WIKI.logger.info(`(STORAGE/DISK) Creating file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.code !== page.localeCode) { if (WIKI.config.lang.code !== page.localeCode) {
fileName = `${page.localeCode}/${fileName}` fileName = `${page.localeCode}/${fileName}`
@ -54,7 +54,7 @@ module.exports = {
await fs.outputFile(filePath, page.injectMetadata(), 'utf8') await fs.outputFile(filePath, page.injectMetadata(), 'utf8')
}, },
async updated(page) { async updated(page) {
WIKI.logger.info(`(STORAGE/DISK) Updating file ${page.path}...`)
WIKI.logger.info(`(STORAGE/DISK) Updating file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.code !== page.localeCode) { if (WIKI.config.lang.code !== page.localeCode) {
fileName = `${page.localeCode}/${fileName}` fileName = `${page.localeCode}/${fileName}`
@ -63,7 +63,7 @@ module.exports = {
await fs.outputFile(filePath, page.injectMetadata(), 'utf8') await fs.outputFile(filePath, page.injectMetadata(), 'utf8')
}, },
async deleted(page) { async deleted(page) {
WIKI.logger.info(`(STORAGE/DISK) Deleting file ${page.path}...`)
WIKI.logger.info(`(STORAGE/DISK) Deleting file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.code !== page.localeCode) { if (WIKI.config.lang.code !== page.localeCode) {
fileName = `${page.localeCode}/${fileName}` fileName = `${page.localeCode}/${fileName}`
@ -72,7 +72,8 @@ module.exports = {
await fs.unlink(filePath) await fs.unlink(filePath)
}, },
async renamed(page) { async renamed(page) {
WIKI.logger.info(`(STORAGE/DISK) Renaming file ${page.path} to ${page.destinationPath}...`)
WIKI.logger.info(`(STORAGE/DISK) Renaming file [${page.localeCode}] ${page.path} to [${page.destinationLocaleCode}] ${page.destinationPath}...`)
let sourceFilePath = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let sourceFilePath = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
let destinationFilePath = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}` let destinationFilePath = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}`

8
server/modules/storage/git/storage.js

@ -214,7 +214,7 @@ module.exports = {
* @param {Object} page Page to create * @param {Object} page Page to create
*/ */
async created(page) { async created(page) {
WIKI.logger.info(`(STORAGE/GIT) Committing new file ${page.path}...`)
WIKI.logger.info(`(STORAGE/GIT) Committing new file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) { if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
fileName = `${page.localeCode}/${fileName}` fileName = `${page.localeCode}/${fileName}`
@ -233,7 +233,7 @@ module.exports = {
* @param {Object} page Page to update * @param {Object} page Page to update
*/ */
async updated(page) { async updated(page) {
WIKI.logger.info(`(STORAGE/GIT) Committing updated file ${page.path}...`)
WIKI.logger.info(`(STORAGE/GIT) Committing updated file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) { if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
fileName = `${page.localeCode}/${fileName}` fileName = `${page.localeCode}/${fileName}`
@ -252,7 +252,7 @@ module.exports = {
* @param {Object} page Page to delete * @param {Object} page Page to delete
*/ */
async deleted(page) { async deleted(page) {
WIKI.logger.info(`(STORAGE/GIT) Committing removed file ${page.path}...`)
WIKI.logger.info(`(STORAGE/GIT) Committing removed file [${page.localeCode}] ${page.path}...`)
let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) { if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
fileName = `${page.localeCode}/${fileName}` fileName = `${page.localeCode}/${fileName}`
@ -269,7 +269,7 @@ module.exports = {
* @param {Object} page Page to rename * @param {Object} page Page to rename
*/ */
async renamed(page) { async renamed(page) {
WIKI.logger.info(`(STORAGE/GIT) Committing file move from ${page.path} to ${page.destinationPath}...`)
WIKI.logger.info(`(STORAGE/GIT) Committing file move from [${page.localeCode}] ${page.path} to [${page.destinationLocaleCode}] ${page.destinationPath}...`)
let sourceFilePath = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` let sourceFilePath = `${page.path}.${pageHelper.getFileExtension(page.contentType)}`
let destinationFilePath = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}` let destinationFilePath = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}`

Loading…
Cancel
Save