accept build id parameter when serving static files

This commit is contained in:
Brian Gough
2015-02-25 17:05:19 +00:00
parent b8cdd4fa85
commit 151ea99639
4 changed files with 28 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ module.exports = OutputCacheManager =
# copy all the output files into it
#
# TODO: use Path module
buildId = 'build-' + Date.now()
buildId = Date.now()
relDir = OutputCacheManager.CACHE_DIR + '/' + buildId
newDir = target + '/' + relDir
OutputCacheManager.expireOutputFiles target
@@ -25,9 +25,8 @@ module.exports = OutputCacheManager =
else
async.mapSeries outputFiles, (file, cb) ->
newFile = _.clone(file)
newFile.path = relDir + '/' + file.path
src = target + '/' + file.path
dst = target + '/' + newFile.path
dst = target + '/' + relDir + '/' + file.path
#console.log 'src', src, 'dst', dst
fs.stat src, (err, stats) ->
if err?
@@ -36,6 +35,8 @@ module.exports = OutputCacheManager =
#console.log 'isFile: copying'
fse.copy src, dst, (err) ->
OutputFileOptimiser.optimiseFile src, dst, (err, result) ->
console.log 'setting buildId on', newFile, 'to', buildId
newFile.build = buildId
cb(err, newFile)
else
# other filetype - shouldn't happen