scaffolding project size

This commit is contained in:
Henrique Santos 2016-03-11 22:31:46 -03:00
parent 8ddfbb99de
commit 099d0fef2f
3 changed files with 25 additions and 0 deletions

View file

@ -85,6 +85,8 @@ app.post "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey
app.put "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, express.bodyParser(), fileController.copyFile
app.del "/project/:project_id/public/:public_file_id", keyBuilder.publicFileKey, fileController.deleteFile
app.get "project/:project_id/size", keyBuilder.publicProjectKey, projectController.projectSize
app.get "/heapdump", (req, res)->
require('heapdump').writeSnapshot '/tmp/' + Date.now() + '.filestore.heapsnapshot', (err, filename)->
res.send filename

View file

@ -42,4 +42,9 @@ module.exports =
opts = req.query
next()
publicProjectKey: (req, res, next)->
{project_id} = req.params
req.project_id = project_id
req.bucket = settings.filestore.stores.user_files
next()

View file

@ -0,0 +1,18 @@
settings = require("settings-sharelatex")
logger = require("logger-sharelatex")
metrics = require("metrics-sharelatex")
Errors = require('./Errors')
module.exports = projectController =
projectSize: (req, res)->
metrics.inc "projectSize"
{project_id, bucket} = req
logger.log project_id:project_id, bucket:bucket, "reciving request to project size"
FileHandler.getFile bucket, project_id, req, (err)->
if err?
logger.log err: err, project_id: project_id, bucket: bucket, "error inserting file"
res.send 500
else
res.send 200