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

View File

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