         status: "Invalid PDF file"
 
 importFile = (file) ->
+  console.log "Import file called"
   reader = new FileReader()
   reader.onload = ->
     fileContent = @result
-
     testPDF file, fileContent, ->
-      hash = new Crypto.SHA256
-        onProgress: (progress) ->
-          #TODO: update progressbar
-      hash.update fileContent, (error, result) ->
-        #TODO: handle errors
-        if error
-          console.log "Import error: " + error.message
-      hash.finalize (error, result) ->
-        #TODO: handle errors
-        if error
-          console.log "Import error: " + error.message
-        sha256 = result
-
-        alreadyImporting = ImportingFile.documents.findOne(sha256: sha256)
-        if alreadyImporting
-          ImportingFile.documents.update file._id,
-            $set:
-              finished: true
-              status: "File is already importing"
-              # publicationId might not yet be available, but let's try
-              publicationId: alreadyImporting.publicationId
-          return
-
-        ImportingFile.documents.update file._id,
-          $set:
-            sha256: sha256
-
-        Meteor.call 'create-publication', file.name, sha256, (error, result) ->
-          if error
-            ImportingFile.documents.update file._id,
-              $set:
-                errored: true
-                status: error.toString()
-            return
-
-          if result.already
-            ImportingFile.documents.update file._id,
-              $set:
-                finished: true
-                status: "File already imported"
-                publicationId: result.publicationId
-            return
-
-          if result.verify
-            verifyFile file, fileContent, result.publicationId, result.samples
-          else
-            uploadFile file, result.publicationId
-
+      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"

    uploadProgress: 0
    finished: false
    errored: false
  ,
    # We are using callback to make sure ImportingFiles really has the file now
    (error, id) ->

          finished: true
          publicationId: publicationId

testPDF = (file, fileContent, callback) ->
  PDFJS.getDocument(data: fileContent, password: '').then callback, (message, exception) ->
    ImportingFile.documents.update file._id,
