Browse Source

fix: git sync untracked

pull/1080/head
Nick 5 years ago
parent
commit
454da698a1
3 changed files with 15 additions and 9 deletions
  1. 13
      server/helpers/page.js
  2. 9
      server/models/pages.js
  3. 2
      server/modules/storage/git/storage.js

13
server/helpers/page.js

@ -89,5 +89,18 @@ module.exports = {
} else { } else {
return false return false
} }
},
/**
* Get file extension from content type
*/
getFileExtension(contentType) {
switch (contentType) {
case 'markdown':
return 'md'
case 'html':
return 'html'
default:
return 'txt'
}
} }
} }

9
server/models/pages.js

@ -159,14 +159,7 @@ module.exports = class Page extends Model {
* @returns {string} File Extension * @returns {string} File Extension
*/ */
getFileExtension() { getFileExtension() {
switch (this.contentType) {
case 'markdown':
return 'md'
case 'html':
return 'html'
default:
return 'txt'
}
return pageHelper.getFileExtension(this.contentType)
} }
/** /**

2
server/modules/storage/git/storage.js

@ -349,7 +349,7 @@ module.exports = {
new stream.Transform({ new stream.Transform({
objectMode: true, objectMode: true,
transform: async (page, enc, cb) => { transform: async (page, enc, cb) => {
let fileName = `${page.path}.${page.getFileExtension()}`
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}`
} }

Loading…
Cancel
Save