added missing files

This commit is contained in:
Henry Oswald 2016-12-14 17:14:15 +00:00
parent 676d832b2f
commit 4bba56ed28
2 changed files with 104 additions and 0 deletions

View file

@ -0,0 +1,46 @@
fs = require("fs-extra")
path = require("path")
async = require("async")
fileConverter = require("./FileConverter")
keyBuilder = require("./KeyBuilder")
fileController = require("./FileController")
logger = require('logger-sharelatex')
settings = require("settings-sharelatex")
streamBuffers = require("stream-buffers")
checkCanStoreFiles = (callback)->
req = {params:{}, query:{}, headers:{}}
res = {}
req.params.project_id = settings.health_check.project_id
req.params.file_id = settings.health_check.file_id
myWritableStreamBuffer = new streamBuffers.WritableStreamBuffer(initialSize: 100)
keyBuilder.userFileKey req, res, ->
fileController.getFile req, myWritableStreamBuffer
myWritableStreamBuffer.on "close", ->
if myWritableStreamBuffer.size() > 0
callback()
else
logger.err "no data in write stream buffer for health check"
callback()
checkFileConvert = (callback)->
imgPath = path.join(settings.path.uploadFolder, "/tiny.pdf")
console.log imgPath, settings.path.uploadFolder
async.waterfall [
(cb)->
fs.copy("./tiny.pdf", imgPath, cb)
(cb)-> fileConverter.thumbnail "./tiny.pdf", cb
(resultPath, cb)-> fs.unlink resultPath, cb
(resultPath, cb)-> fs.unlink imgPath, cb
], callback
module.exports =
check: (req, res)->
async.parallel [checkFileConvert, checkCanStoreFiles], (err)->
if err?
logger.err err:err, "Health check: error running"
return res.send 500
else
return res.send 200

View file

@ -0,0 +1,58 @@
%PDF-1.1
%¥±ë
1 0 obj
<< /Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<< /Type /Pages
/Kids [3 0 R]
/Count 1
/MediaBox [0 0 300 144]
>>
endobj
3 0 obj
<< /Type /Page
/Parent 2 0 R
/Resources
<< /Font
<< /F1
<< /Type /Font
/Subtype /Type1
/BaseFont /Times-Roman
>>
>>
>>
/Contents 4 0 R
>>
endobj
4 0 obj
<< /Length 55 >>
stream
BT
/F1 18 Tf
0 0 Td
(Hello World) Tj
ET
endstream
endobj
xref
0 5
0000000000 65535 f
0000000018 00000 n
0000000077 00000 n
0000000178 00000 n
0000000457 00000 n
trailer
<< /Root 1 0 R
/Size 5
>>
startxref
565
%%EOF