Verified Commit 5987eeaa authored by Frauke's avatar Frauke

Changed directory of uploaded files

parent 12adf9a8
const fileUtils = require('../helpers/fileUtils')
const os = require('os')
const path = require('path')
const dataDirectoryPath = path.join(os.homedir(), '.hallo.gent')
module.exports = (image, original) => {
if (image === '' && original && original !== '') {
// Original image was removed and no new image was uploaded, so remove original image.
fileUtils.removeFile(`./client/static${original}`).catch(err => {
fileUtils.removeFile(`${dataDirectoryPath}${original}`).catch(err => {
throw err
})
image = null
} else if (image && image !== '' && (!original || original === '' || image !== original)) {
// An image was uploaded, save only the path to the image
image = `${image[0].destination.replace('./client/static', '')}/${image[0].filename}`
image = `${image[0].destination.replace(${dataDirectoryPath}, '')}/${image[0].filename}`
// And remove originalImage if present
if (!original && original !== '') {
fileUtils.removeFile(`./client/static${original}`).catch(err => {
fileUtils.removeFile(`${dataDirectoryPath}${original}`).catch(err => {
throw err
})
}
......
const PendingSite = require('../../db/models/pendingSite')
const messagesDb = require('../../db/services/messagesDb')
const fileUtils = require('../../helpers/fileUtils')
const os = require('os')
const path = require('path')
const dataDirectoryPath = path.join(os.homedir(), '.hallo.gent')
class Service {
constructor (options) {
......@@ -25,7 +28,7 @@ class Service {
await site.remove()
// Delete images from site
await fileUtils.removeDir(`./client/static/uploads/${id}`)
await fileUtils.removeDir(`${dataDirectoryPath}/uploads/${id}`)
// delete the conversation on the server.
await messagesDb.deleteConversation(metaData.accountCode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment