refactor: removed redis + new scheduler engine
This commit is contained in:
@@ -1,26 +1,24 @@
|
||||
require('../core/worker')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
const fs = require('fs-extra')
|
||||
const moment = require('moment')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = async (job) => {
|
||||
module.exports = async () => {
|
||||
WIKI.logger.info('Purging orphaned upload files...')
|
||||
|
||||
try {
|
||||
const uplTempPath = path.resolve(process.cwd(), WIKI.config.paths.data, 'uploads')
|
||||
const ls = await fs.readdirAsync(uplTempPath)
|
||||
const ls = await fs.readdir(uplTempPath)
|
||||
const fifteenAgo = moment().subtract(15, 'minutes')
|
||||
|
||||
await Promise.map(ls, (f) => {
|
||||
return fs.statAsync(path.join(uplTempPath, f)).then((s) => { return { filename: f, stat: s } })
|
||||
return fs.stat(path.join(uplTempPath, f)).then((s) => { return { filename: f, stat: s } })
|
||||
}).filter((s) => { return s.stat.isFile() }).then((arrFiles) => {
|
||||
return Promise.map(arrFiles, (f) => {
|
||||
if (moment(f.stat.ctime).isBefore(fifteenAgo, 'minute')) {
|
||||
return fs.unlinkAsync(path.join(uplTempPath, f.filename))
|
||||
return fs.unlink(path.join(uplTempPath, f.filename))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user