           finished: true
           publicationId: publicationId
 
-  ImportingFile.documents.update file._id,
-    $set:
-      status: "In queue"
-
-
 testPDF = (file, fileContent, callback) ->
   PDFJS.getDocument(data: fileContent, password: '').then callback, (message, exception) ->
     ImportingFile.documents.update file._id,

        finished: true
        publicationId: publicationId


uploadQueue = async.queue (params, callback) ->
  meteorFile = new MeteorFile params.file,
    collection: ImportingFile.Meta.collection

  meteorFile.upload params.file, 'upload-publication',
    size: UPLOAD_CHUNK_SIZE,
    publicationId: params.publicationId
  ,
    callback
,
  1 # simultaneous upload(s)

uploadFile = (file, publicationId) ->
  uploadQueue.push
    file: file
    publicationId: publicationId
  ,
    (error) ->

        status: "Invalid PDF file"

importFile = (file) ->
  console.log "Import file called"
  reader = new FileReader()
  reader.onload = ->
    fileContent = @result
    testPDF file, fileContent, ->
      fileBuffer[file._id] =
        file: file
        fileContent: fileContent

      ImportingFile.documents.update file._id,
        $set:
          status: "In queue for checksum computation"
          preprocessed: true

  console.log "Inserting file into collection " + file.name
  ImportingFile.documents.insert
    name: file.name
    status: "Preprocessing file"
