       attributes: href: "#"
       click     : => @emit "cancel"
 
-  saveFile: (uploadFile, data)->
-    @emit "uploadStart", uploadFile
-    uploadFile.saveBinary data, (err, res, progress)=>
+  saveFile: (fsFile, data)->
+    @emit "uploadStart", fsFile
+    fsFile.saveBinary data, (err, res, progress)=>
       return if err
       if res.finished
-        @emit "uploadEnd", uploadFile
+        @emit "uploadEnd", fsFile
       else if res.abort
-        @emit "uploadAbort", uploadFile
+        @emit "uploadAbort", fsFile
       else
-        @emit "uploadFile", uploadFile, progress.percent
+        @emit "uploadFile", fsFile, progress.percent
 
-  upload: (file, data)->
-    modalStack  = KDModalView.createStack lastToFirst: yes
-    uploadDir   = FSHelper.createFileFromPath @path, 'folder'
-    uploadFile  = FSHelper.createFileFromPath "#{@path}/#{file}"
+  upload: (fileName, contents)->
+    modalStack      = KDModalView.createStack lastToFirst: yes
+    fsUploadFolder  = FSHelper.createFileFromPath @path, 'folder'
+    fsFileToUpload  = FSHelper.createFileFromPath "#{@path}/#{fileName}"
 
-    upload      = =>
-      uploadFile.exists (err, exists)=>
-        unless exists
-        then @saveFile uploadFile, data
+    upload = =>
+      fsFileToUpload.exists (err, exists)=>
+        if not exists or fsFileToUpload.getLocalFileInfo().lastUploadedChunk?
+        then @saveFile fsFileToUpload, contents
         else
           modalStack.addModal modal = new KDModalView
             overlay : no
             title   : "Overwrite File?"
             content : """
             <div class="modalformline">
-            You already have the file <code>#{uploadFile.path}</code>. Do you want
+            You already have the file <code>#{fsFileToUpload.path}</code>. Do you want
             to overwrite it?
             </div>
             """

      @on "dragleave", => @unsetClass "hover"
      @on "drop",      => @unsetClass "hover"

    @on "uploadFile", (file, percent)=>
      finder = KD.getSingleton "finderController"
      filePath  = "[#{file.vmName}]#{file.path}"
      finder.treeController.nodes[filePath]?.updateProgressView percent

    @on "uploadStart", (file)=>
      finder = KD.getSingleton "finderController"
      filePath   = "[#{file.vmName}]#{file.path}"
      parentPath = "[#{file.vmName}]#{file.parentPath}"

      file._isBeingUploaded = yes
      nodeView = finder.treeController.nodes[filePath]
      if nodeView
        nodeView.updateProgressView 1
        nodeView.on "abortProgress", => file.abort yes
      else
        finder.treeController.on "NodeWasAdded", (nodeView)->
          if nodeView.getData().path is filePath and file._isBeingUploaded
            nodeView.updateProgressView 1
            nodeView.on "abortProgress", => file.abort yes

        file.save "", -> finder.revealPath parentPath

    @on "uploadEnd", (file)->
      file._isBeingUploaded = no

  reset: ->
    {uploadToVM, defaultPath, title} = @getOptions()

                callback: ->
                  modalStack.destroy()

    fsUploadFolder.exists (err, exists)=>
      unless exists
      then fsUploadFolder.save -> upload()
      else upload()

    return fsFileToUpload
