Use fs-extra for move vs fs.rename(), start replace of mkdirp

This commit is contained in:
Bryan Ashby 2016-03-27 23:19:18 -06:00
parent 38a96f53da
commit 8645cac892
2 changed files with 7 additions and 6 deletions

View File

@ -15,13 +15,13 @@ let Message = require('../message.js');
let moment = require('moment');
let _ = require('lodash');
let paths = require('path');
let mkdirp = require('mkdirp');
let async = require('async');
let fs = require('fs');
let later = require('later');
let temp = require('temp').track(); // track() cleans up temp dir/files for us
let assert = require('assert');
let gaze = require('gaze');
let fse = require('fs-extra');
exports.moduleInfo = {
name : 'FTN BSO',
@ -627,7 +627,7 @@ function FTNMessageScanTossModule() {
async.waterfall(
[
function createOutgoingDir(callback) {
mkdirp(outgoingDir, err => {
fse.mkdirs(outgoingDir, err => {
callback(err);
});
},
@ -680,13 +680,13 @@ function FTNMessageScanTossModule() {
outgoingDir,
`${paths.basename(oldPath, 'pk_')}${ext}`);
fs.rename(oldPath, newPath, nextFile);
fse.move(oldPath, newPath, nextFile);
} else {
const newPath = paths.join(outgoingDir, paths.basename(oldPath));
fs.rename(oldPath, newPath, err => {
fse.move(oldPath, newPath, err => {
if(err) {
Log.warn(
{ oldPath : oldPath, newPath : newPath },
{ oldPath : oldPath, newPath : newPath, error : err.toString() },
'Failed moving temporary bundle file!');
return nextFile();

View File

@ -30,7 +30,8 @@
"sqlite3": "^3.1.1",
"ssh2": "^0.4.13",
"string-format": "davidchambers/string-format#mini-language",
"temp": "^0.8.3"
"temp": "^0.8.3",
"fs-extra" : "0.26.x"
},
"engines": {
"node": ">=0.12.2"