mirror of https://github.com/status-im/codimd.git
refactor: fix lint on lib/web/userRouter.js
Signed-off-by: BoHong Li <raccoon@hackmd.io>
This commit is contained in:
parent
3049c64066
commit
ee1538eed9
|
@ -69,8 +69,7 @@ UserRouter.get('/me/delete/:token?', function (req, res) {
|
||||||
// export the data of the authenticated user
|
// export the data of the authenticated user
|
||||||
UserRouter.get('/me/export', function (req, res) {
|
UserRouter.get('/me/export', function (req, res) {
|
||||||
if (req.isAuthenticated()) {
|
if (req.isAuthenticated()) {
|
||||||
// let output = fs.createWriteStream(__dirname + '/example.zip');
|
const archive = archiver('zip', {
|
||||||
let archive = archiver('zip', {
|
|
||||||
zlib: { level: 3 } // Sets the compression level.
|
zlib: { level: 3 } // Sets the compression level.
|
||||||
})
|
})
|
||||||
res.setHeader('Content-Type', 'application/zip')
|
res.setHeader('Content-Type', 'application/zip')
|
||||||
|
@ -90,14 +89,14 @@ UserRouter.get('/me/export', function (req, res) {
|
||||||
ownerId: user.id
|
ownerId: user.id
|
||||||
}
|
}
|
||||||
}).then(function (notes) {
|
}).then(function (notes) {
|
||||||
let filenames = {}
|
const filenames = {}
|
||||||
async.each(notes, function (note, callback) {
|
async.each(notes, function (note, callback) {
|
||||||
let basename = note.title.replace(/\//g, '-') // Prevent subdirectories
|
let basename = note.title.replace(/\//g, '-') // Prevent subdirectories
|
||||||
let filename
|
let filename
|
||||||
let suffix = ''
|
let suffix = 0
|
||||||
do {
|
do {
|
||||||
let seperator = typeof suffix === 'number' ? '-' : ''
|
const separator = suffix === 0 ? '' : '-'
|
||||||
filename = basename + seperator + suffix + '.md'
|
filename = basename + separator + suffix + '.md'
|
||||||
suffix++
|
suffix++
|
||||||
} while (filenames[filename])
|
} while (filenames[filename])
|
||||||
filenames[filename] = true
|
filenames[filename] = true
|
||||||
|
|
Loading…
Reference in New Issue