refactor: fix lint on lib/web/userRouter.js

Signed-off-by: BoHong Li <raccoon@hackmd.io>
This commit is contained in:
BoHong Li 2019-08-02 01:00:46 +08:00
parent 3049c64066
commit ee1538eed9
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38
1 changed files with 5 additions and 6 deletions

View File

@ -69,8 +69,7 @@ UserRouter.get('/me/delete/:token?', function (req, res) {
// export the data of the authenticated user
UserRouter.get('/me/export', function (req, res) {
if (req.isAuthenticated()) {
// let output = fs.createWriteStream(__dirname + '/example.zip');
let archive = archiver('zip', {
const archive = archiver('zip', {
zlib: { level: 3 } // Sets the compression level.
})
res.setHeader('Content-Type', 'application/zip')
@ -90,14 +89,14 @@ UserRouter.get('/me/export', function (req, res) {
ownerId: user.id
}
}).then(function (notes) {
let filenames = {}
const filenames = {}
async.each(notes, function (note, callback) {
let basename = note.title.replace(/\//g, '-') // Prevent subdirectories
let filename
let suffix = ''
let suffix = 0
do {
let seperator = typeof suffix === 'number' ? '-' : ''
filename = basename + seperator + suffix + '.md'
const separator = suffix === 0 ? '' : '-'
filename = basename + separator + suffix + '.md'
suffix++
} while (filenames[filename])
filenames[filename] = true