Skip to content

Commit

Permalink
Change partialCache behavior
Browse files Browse the repository at this point in the history
don't use .processing extension for partialCache
this allows the partial cache to be used at anytime
  • Loading branch information
chmille4 committed Jul 15, 2016
1 parent 895a2ff commit 287000c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,20 @@ cmd.prototype.run = function(clients, serverAddress) {
self.emit('log', 'caching ' + self.opts.cachePath);
var cacheDir = require('path').dirname(self.opts.cachePath)
mkdirp( cacheDir , function (err) {if (err) console.error(err)});
var ws = fs.createWriteStream(self.opts.cachePath + '.processing', {flags: 'wx', mode:0600})
var processingExtension = self.params.partialCache === 'true' ? '' : '.processing';

var ws = fs.createWriteStream(self.opts.cachePath + processingExtension, {flags: 'wx', mode:0600})
ws.on('error', function(error) {
if (error.code != 'EEXIST')
console.error(error)
})

// Remove .processing extension from cache file when cache has finished being written
ws.on('finish', function() {
fs.rename(self.opts.cachePath + '.processing', self.opts.cachePath, function(err) {
if ( err ) console.error('ERROR Renaming Cache file: ' + err);
})
if (self.params.partialCache !== 'true')
fs.rename(self.opts.cachePath + processingExtension, self.opts.cachePath, function(err) {
if ( err ) console.error('ERROR Renaming Cache file: ' + err);
})
})

// if tool has cacheTransform pipe through it before caching
Expand Down

0 comments on commit 287000c

Please sign in to comment.