|
@@ -5,12 +5,16 @@ Path = require "path"
|
|
|
logger = require "logger-sharelatex"
|
|
logger = require "logger-sharelatex"
|
|
|
_ = require "underscore"
|
|
_ = require "underscore"
|
|
|
|
|
|
|
|
|
|
+OutputFileOptimiser = require "./OutputFileOptimiser"
|
|
|
|
|
+
|
|
|
module.exports = OutputCacheManager =
|
|
module.exports = OutputCacheManager =
|
|
|
CACHE_DIR: '.cache/clsi'
|
|
CACHE_DIR: '.cache/clsi'
|
|
|
|
|
|
|
|
saveOutputFiles: (outputFiles, target, callback) ->
|
|
saveOutputFiles: (outputFiles, target, callback) ->
|
|
|
# make a target/build_id directory and
|
|
# make a target/build_id directory and
|
|
|
# copy all the output files into it
|
|
# copy all the output files into it
|
|
|
|
|
+ #
|
|
|
|
|
+ # TODO: use Path module
|
|
|
buildId = 'build-' + Date.now()
|
|
buildId = 'build-' + Date.now()
|
|
|
relDir = OutputCacheManager.CACHE_DIR + '/' + buildId
|
|
relDir = OutputCacheManager.CACHE_DIR + '/' + buildId
|
|
|
newDir = target + '/' + relDir
|
|
newDir = target + '/' + relDir
|
|
@@ -31,7 +35,8 @@ module.exports = OutputCacheManager =
|
|
|
else if stats.isFile()
|
|
else if stats.isFile()
|
|
|
#console.log 'isFile: copying'
|
|
#console.log 'isFile: copying'
|
|
|
fse.copy src, dst, (err) ->
|
|
fse.copy src, dst, (err) ->
|
|
|
- cb(err, newFile)
|
|
|
|
|
|
|
+ OutputFileOptimiser.optimiseFile src, dst, (err, result) ->
|
|
|
|
|
+ cb(err, newFile)
|
|
|
else
|
|
else
|
|
|
# other filetype - shouldn't happen
|
|
# other filetype - shouldn't happen
|
|
|
cb(new Error("output file is not a file"), file)
|
|
cb(new Error("output file is not a file"), file)
|