Fix local attachments when temp dir and bot dir are on different drives
parent
6c10b088a8
commit
5244cce31c
|
@ -2082,6 +2082,38 @@
|
||||||
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",
|
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"mv": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mv/-/mv-2.1.1.tgz",
|
||||||
|
"integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=",
|
||||||
|
"requires": {
|
||||||
|
"mkdirp": "~0.5.1",
|
||||||
|
"ncp": "~2.0.0",
|
||||||
|
"rimraf": "~2.4.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"glob": {
|
||||||
|
"version": "6.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz",
|
||||||
|
"integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=",
|
||||||
|
"requires": {
|
||||||
|
"inflight": "^1.0.4",
|
||||||
|
"inherits": "2",
|
||||||
|
"minimatch": "2 || 3",
|
||||||
|
"once": "^1.3.0",
|
||||||
|
"path-is-absolute": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.4.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz",
|
||||||
|
"integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=",
|
||||||
|
"requires": {
|
||||||
|
"glob": "^6.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"nan": {
|
"nan": {
|
||||||
"version": "2.14.0",
|
"version": "2.14.0",
|
||||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
|
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
|
||||||
|
@ -2111,6 +2143,11 @@
|
||||||
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ncp": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M="
|
||||||
|
},
|
||||||
"needle": {
|
"needle": {
|
||||||
"version": "2.4.0",
|
"version": "2.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz",
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
"knub-command-manager": "^3.1.3",
|
"knub-command-manager": "^3.1.3",
|
||||||
"mime": "^2.3.1",
|
"mime": "^2.3.1",
|
||||||
"moment": "^2.21.0",
|
"moment": "^2.21.0",
|
||||||
|
"mv": "^2.1.1",
|
||||||
"public-ip": "^2.0.1",
|
"public-ip": "^2.0.1",
|
||||||
"sqlite3": "^4.0.9",
|
"sqlite3": "^4.0.9",
|
||||||
"tmp": "0.0.33",
|
"tmp": "0.0.33",
|
||||||
|
|
|
@ -5,12 +5,12 @@ const {promisify} = require('util');
|
||||||
const tmp = require('tmp');
|
const tmp = require('tmp');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
|
const mv = promisify(require('mv'));
|
||||||
|
|
||||||
const getUtils = () => require('../utils');
|
const getUtils = () => require('../utils');
|
||||||
|
|
||||||
const access = promisify(fs.access);
|
const access = promisify(fs.access);
|
||||||
const readFile = promisify(fs.readFile);
|
const readFile = promisify(fs.readFile);
|
||||||
const rename = promisify(fs.rename);
|
|
||||||
|
|
||||||
const localAttachmentDir = config.attachmentDir || `${__dirname}/../../attachments`;
|
const localAttachmentDir = config.attachmentDir || `${__dirname}/../../attachments`;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ async function saveLocalAttachment(attachment) {
|
||||||
const downloadResult = await downloadAttachment(attachment);
|
const downloadResult = await downloadAttachment(attachment);
|
||||||
|
|
||||||
// Move the temp file to the attachment folder
|
// Move the temp file to the attachment folder
|
||||||
await rename(downloadResult.path, targetPath);
|
await mv(downloadResult.path, targetPath);
|
||||||
|
|
||||||
// Resolve the attachment URL
|
// Resolve the attachment URL
|
||||||
const url = await getLocalAttachmentUrl(attachment.id, attachment.filename);
|
const url = await getLocalAttachmentUrl(attachment.id, attachment.filename);
|
||||||
|
|
Loading…
Reference in New Issue