From 396644d314b1c2fbc84a5042ed296005aafe6df8 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 15 Apr 2015 14:41:38 +0100 Subject: [PATCH 1/2] proposed fix to delete tpds dump files after use --- .../Features/ThirdPartyDataStore/UpdateMerger.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/ThirdPartyDataStore/UpdateMerger.coffee b/services/web/app/coffee/Features/ThirdPartyDataStore/UpdateMerger.coffee index 887168fc9e..d18a8713ab 100644 --- a/services/web/app/coffee/Features/ThirdPartyDataStore/UpdateMerger.coffee +++ b/services/web/app/coffee/Features/ThirdPartyDataStore/UpdateMerger.coffee @@ -19,11 +19,16 @@ module.exports = if element? elementId = element._id self.p.writeStreamToDisk project_id, elementId, updateRequest, (err, fsPath)-> + callback = _.wrap callback, (cb, arg) -> + fs.unlink fsPath, (err) -> + if err? + logger.err project_id:project_id, fsPath:fsPath, "error deleting file" + cb(arg) return callback(err) if err? FileTypeManager.isBinary path, fsPath, (err, isFile)-> return callback(err) if err? if isFile - self.p.processFile project_id, elementId, fsPath, path, source, callback #TODO clean up the stream written to disk here + self.p.processFile project_id, elementId, fsPath, path, source, callback else self.p.processDoc project_id, elementId, fsPath, path, source, callback From 7a46b98c822e4e57f244e0ff3c47f495f8bf70a4 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 22 Apr 2015 15:08:29 +0100 Subject: [PATCH 2/2] fixed unit tests for deleting files sent from tpds --- .../coffee/ThirdPartyDataStore/UpdateMergerTests.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee index 61ff8da023..251c383a9d 100644 --- a/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee +++ b/services/web/test/UnitTests/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee @@ -11,7 +11,8 @@ describe 'UpdateMerger :', -> @updateReciver = {} @projectLocator = {} @projectEntityHandler = {} - @fs = {} + @fs = + unlink:sinon.stub().callsArgWith(1) @FileTypeManager = {} @updateMerger = SandboxedModule.require modulePath, requires: '../Editor/EditorController': @editorController @@ -50,6 +51,7 @@ describe 'UpdateMerger :', -> @updateMerger.mergeUpdate @project_id, filePath, @update, @source, => @FileTypeManager.isBinary.calledWith(filePath, @fsPath).should.equal true @updateMerger.p.processDoc.calledWith(@project_id, doc_id, @fsPath, filePath, @source).should.equal true + @fs.unlink.calledWith(@fsPath).should.equal true done() it 'should process update as file when it is not a doc', (done)-> @@ -62,6 +64,7 @@ describe 'UpdateMerger :', -> @updateMerger.mergeUpdate @project_id, filePath, @update, @source, => @updateMerger.p.processFile.calledWith(@project_id, file_id, @fsPath, filePath, @source).should.equal true @FileTypeManager.isBinary.calledWith(filePath, @fsPath).should.equal true + @fs.unlink.calledWith(@fsPath).should.equal true done()