mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-24 03:30:40 +02:00
* 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:
parent
e10d085cab
commit
9525afddd3
5 changed files with 33 additions and 39 deletions
|
@ -9,6 +9,7 @@ const FileEntry = require('./file_entry.js');
|
|||
const FileDb = require('./database.js').dbs.file;
|
||||
const ArchiveUtil = require('./archive_util.js');
|
||||
const CRC32 = require('./crc.js').CRC32;
|
||||
const Log = require('./logger.js').log;
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
|
@ -16,7 +17,7 @@ const async = require('async');
|
|||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
const paths = require('path');
|
||||
const temp = require('temp').track(); // track() cleans up temp dir/files for us
|
||||
const temptmp = require('temptmp').createTrackedSession('file_area');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
exports.isInternalArea = isInternalArea;
|
||||
|
@ -298,7 +299,7 @@ function populateFileEntryWithArchive(fileEntry, filePath, stepInfo, iterator, c
|
|||
return callback(null, [] );
|
||||
}
|
||||
|
||||
temp.mkdir('enigextract-', (err, tempDir) => {
|
||||
temptmp.mkdir( { prefix : 'enigextract-' }, (err, tempDir) => {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -338,14 +339,11 @@ function populateFileEntryWithArchive(fileEntry, filePath, stepInfo, iterator, c
|
|||
return next(null);
|
||||
});
|
||||
}, () => {
|
||||
// cleanup, but don't wait...
|
||||
/*
|
||||
:TODO: fix global temp cleanup issue!!!
|
||||
|
||||
temp.cleanup( err => {
|
||||
// :TODO: Log me!
|
||||
});*/
|
||||
|
||||
// cleanup but don't wait
|
||||
temptmp.cleanup( paths => {
|
||||
// note: don't use client logger here - may not be avail
|
||||
Log.debug( { paths : paths, sessionId : temptmp.sessionId }, 'Cleaned up temporary files' );
|
||||
});
|
||||
return callback(null);
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue