Skip to content

Commit

Permalink
Merge pull request #331 from derwok/dev
Browse files Browse the repository at this point in the history
Delay the preCollection remove after upload to workaround sporadic timing issue. Fixes #324
  • Loading branch information
dr-dimitru authored Jan 19, 2017
2 parents 083ad67 + 01dae6d commit 4dc0229
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions files.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,9 @@ class FilesCollection
cb and cb error
console.error '[FilesCollection] [Upload] [_finishUpload] Error:', error if self.debug
else
self._preCollection.update {_id: opts.fileId}, {$set: {isFinished: true}}, () ->
self._preCollection.update {_id: opts.fileId}, {$set: {isFinished: true}}
# we delay the remove to resolve timing issues (details see #324)
Meteor.setTimeout ->
self._preCollection.remove {_id: opts.fileId}, (error) ->
if error
cb and cb error
Expand All @@ -1085,10 +1087,12 @@ class FilesCollection
self.onAfterUpload and self.onAfterUpload.call self, result
self.emit 'afterUpload', result
cb and cb null, result
return
return
return
return
return # .remove
return # .setTimeout
, 25

return # .insert
return # .isServer
else undefined

###
Expand Down

0 comments on commit 4dc0229

Please sign in to comment.