diff --git a/services/filestore/app.coffee b/services/filestore/app.coffee index e78355f4e6..93e86164a7 100644 --- a/services/filestore/app.coffee +++ b/services/filestore/app.coffee @@ -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 diff --git a/services/filestore/app/coffee/KeyBuilder.coffee b/services/filestore/app/coffee/KeyBuilder.coffee index 0b5e41525f..18f1d96952 100644 --- a/services/filestore/app/coffee/KeyBuilder.coffee +++ b/services/filestore/app/coffee/KeyBuilder.coffee @@ -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() diff --git a/services/filestore/app/coffee/ProjectController.coffee b/services/filestore/app/coffee/ProjectController.coffee new file mode 100644 index 0000000000..5ac64dd632 --- /dev/null +++ b/services/filestore/app/coffee/ProjectController.coffee @@ -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 \ No newline at end of file