 
     progressCb = (state) -> @emit("download-progress", state)
 
-    await @_download_update downloadTarget,
+    await @_downloadUpdate downloadTarget,
       "#{@options.updateServer}/#{@options.remoteFilenameOSX}",
       progressCb, defer err
 


    @emit "update-installed"

  _download_update: (targetPath, remoteUrl, progressCb, doneCb) ->
    progress request remoteUrl
      .on 'progress', progressCb
      .on 'error', doneCb
      .pipe fs.createWriteStream targetPath
      .on 'close', doneCb

  _extract_update: (sourceZip, targetFolder, done) ->
    unzipper = new DecompressZip(sourceZip)
    unzipper.on 'error', done
    unzipper.on 'extract', (log) -> done(null)
    unzipper.extract({ path: targetFolder })

  _hide_original_mac: (appPath, appName, cb) ->
    filename = appName + '.app'
    fs.rename appPath + '/' + filename, appPath + '/.' + filename, cb

  _copy_update_mac: (appName, from, to, callback) ->
    wrench.copyDirRecursive from + '/' + appName + '.app',
     to + '/' + appName + '.app',
     {forceDelete: true},
     callback


  _install_update_win: () ->

  _install_update_linux: () ->

  is_update_available: (cb) ->
    options = @options
    request "#{@options.updateServer}/package.json", (error, response, body) ->
      if error?

    console.log @options

  installUpdate: ->
    this._installUpdateMac() if /^darwin/.test process.platform
    this._installUpdateWin() if /^win/.test process.platform
    this._installUpdateLinux() if /^linux/.test process.platform

  _installUpdateMac: ->
    execPath = process.execPath
    filePath = execPath.substr(0, execPath.lastIndexOf("\\"))
    appPath = path.normalize(execPath + "/../../../../../../..")
