Create upload directories if they don't exist

This commit is contained in:
3np 2021-04-06 00:58:25 +09:00
parent e12929960a
commit 3fdccd49d5
3 changed files with 8 additions and 4 deletions

8
app.js
View File

@ -7,7 +7,6 @@ global.ratelimit_counts = {}
global.ratelimit_timestamps = {}
const pug = require('pug')
const path = require('path')
const compression = require('compression')
const express = require('express')
const cookieParser = require('cookie-parser')
@ -53,7 +52,12 @@ const fs = require('fs')
const app = express()
const request = require('postman-request')
const commons = require('./inc/commons.js')(request, fs)
const dlAndSave = require('./inc/downloadAndSave.js')(commons)
const dlAndSave = require('./inc/downloadAndSave.js')(commons);
['pics/thumbs', 'pics/flairs', 'pics/icons', 'vids']
.map(d => `./static/${d}`)
.filter(d => !fs.existsSync(d))
.forEach(d => fs.mkdirSync(d, { recursive: true }))
if(!config.https_enabled && config.redirect_http_to_https) {
console.error(`Cannot redirect HTTP=>HTTPS while "https_enabled" is false.`)

View File

@ -20,7 +20,7 @@ module.exports = function(request, fs) {
if(!error) {
resolve({ success: true })
} else {
resolve({ success: false })
resolve({ success: false, error })
}
})
}).catch((err) => {

View File

@ -89,7 +89,7 @@ module.exports = function(tools) {
let temp_files = [temp_path, audio_path]
deleteFiles(temp_files, (error) => {
if(error) {
console.log(`Error while deleting temporay files:`, error)
console.log(`Error while deleting temporary files:`, error)
}
})
resolve(final_url)