 
 # Process next element from import queue
 Deps.autorun ->
+  # Autorun will not re-run until the same document does not have finished
+  # or errored fields set, but after they are set, next file will be returned
   document = ImportingFile.documents.findOne
     finished: false
     errored: false


UPLOAD_CHUNK_SIZE = 128 * 1024 # bytes
DRAGGING_OVER_DOM = false
importingFiles = {}

# Observes files that are processed and removes them from dictionary
processedFiles = ImportingFile.documents.find()
processedFiles.observeChanges
  removed: (id) ->
    delete importingFiles[id]


verifyFile = (file, publicationId, samples) ->
  ImportingFile.documents.update file._id,


  reader = new FileReader()
  reader.onload = ->
    importingFiles[document._id].content = reader.result
    testPDF importingFiles[document._id], ->
      computeChecksum importingFiles[document._id], (error, sha256) ->
        if error
          ImportingFile.documents.update document._id,
            $set:
