* Created new npm module: temptmp: This replaces node-temp usage & solves global temp file cleanup issue with concept of temp "sessions"

This commit is contained in:
Bryan Ashby 2017-01-29 19:56:46 -07:00
parent e10d085cab
commit 9525afddd3
5 changed files with 33 additions and 39 deletions

View file

@ -10,11 +10,12 @@ const scanFile = require('../core/file_area.js').scanFile;
const ansiGoto = require('../core/ansi_term.js').goto;
const moveFileWithCollisionHandling = require('../core/file_util.js').moveFileWithCollisionHandling;
const pathWithTerminatingSeparator = require('../core/file_util.js').pathWithTerminatingSeparator;
const Log = require('../core/logger.js').log;
// deps
const async = require('async');
const _ = require('lodash');
const temp = require('temp').track(); // track() cleans up temp dir/files for us
const temptmp = require('temptmp').createTrackedSession('upload');
const paths = require('path');
exports.moduleInfo = {
@ -142,15 +143,16 @@ exports.getModule = class UploadModule extends MenuModule {
leave() {
// remove any temp files - only do this when
if(this.isFileTransferComplete()) {
// :TODO: fix global temp cleanup issue!!!
//temp.cleanup(); // remove any temp files
temptmp.cleanup( paths => {
Log.debug( { paths : paths, sessionId : temptmp.sessionId }, 'Temporary files cleaned up' );
});
}
super.leave();
}
performBlindUpload(cb) {
temp.mkdir('enigul-', (err, tempRecvDirectory) => {
temptmp.mkdir( { prefix : 'enigul-' }, (err, tempRecvDirectory) => {
if(err) {
return cb(err);
}