remove unarchived docs from s3

This commit is contained in:
Henrique Dias 2015-06-03 20:05:15 -03:00
parent 9a68bfb393
commit 42f2afc4dd
2 changed files with 9 additions and 2 deletions

View file

@ -60,6 +60,11 @@ module.exports = DocArchive =
return callback new Errors.NotFoundError("Error in S3 request")
MongoManager.upsertIntoDocCollection project_id, doc_id.toString(), lines, (error) ->
return callback(error) if error?
logger.log project_id: project_id, doc_id: doc_id, "deleting doc from s3"
request.del options, (err, res, body)->
if err? || res.statusCode != 204
logger.err err:err, res:res, "something went wrong deleting doc from aws"
return callback new Errors.NotFoundError("Error in S3 request")
callback()
buildS3Options: (content, key)->

View file

@ -25,6 +25,7 @@ describe "DocArchiveManager", ->
@request =
put: {}
get: {}
del: {}
@docs = [{
_id: ObjectId()
@ -99,6 +100,7 @@ describe "DocArchiveManager", ->
it "should use correct options", (done)->
@request.get = sinon.stub().callsArgWith(1, null, statusCode:200, @docs[0].lines)
@request.del = sinon.stub().callsArgWith(1, null, statusCode:204, {})
@requires["request"] = @request
@DocArchiveManager = SandboxedModule.require modulePath, requires: @requires