GitHub PullRequestReviewCommentEvent at 2014-04-27 22:54:44
Repository: GitHubExtIns
Actor: diegocr
Payload: {"comment":{"url":"https://api.github.com/repos/diegocr/GitHubExtIns/pulls/comments/12031923","id":12031923,"diff_hunk":"@@ -127,78 +144,119 @@ function onClickHanlder(ev) {\n \t\t\t\t\t\tzipWriter.addEntryDirectory(n,e.lastModifiedTime,!1);\n \n \t\t\t\t\t} else {\n-\n-\t\t\t\t\t\tzipWriter.addEntryStream(n, e.lastModifiedTime,\n-\t\t\t\t\t\t\tCi.nsIZipWriter.COMPRESSION_FASTEST,\n-\t\t\t\t\t\t\tzipReader.getInputStream(f), !1);\n+\t\t\t\t\t\tif (useUncommitedFilePath && n == useUncommitedFilePath) {\n+\t\t\t\t\t\t\t//skip adding file\n+\t\t\t\t\t\t} else {\t\t\t\t\t\t\t\n+\t\t\t\t\t\t\tzipWriter.addEntryStream(n, e.lastModifiedTime,\n+\t\t\t\t\t\t\t\tCi.nsIZipWriter.COMPRESSION_FASTEST,\n+\t\t\t\t\t\t\t\tzipReader.getInputStream(f), !1);\n+\t\t\t\t\t\t}\n \t\t\t\t\t}\n \t\t\t\t}\n \n-\t\t\t\tzipReader.close();\n-\t\t\t\tzipWriter.close();\n-\n-\t\t\t\tAddonManager.getInstallForFile(oFile,aInstall => {\n-\t\t\t\t\tlet done = (aMsg,aAddon) => {\n-\t\t\t\t\t\tlet c = 'check';\n-\t\t\t\t\t\tif(typeof aMsg === 'number') {\n-\t\t\t\t\t\t\tl.textContent = 'Error ' + aMsg;\n-\t\t\t\t\t\t\taMsg = 'Installation failed ('+aMsg+')';\n-\t\t\t\t\t\t\tc = 'alert';\n-\t\t\t\t\t\t} else {\n-\t\t\t\t\t\t\tl.textContent = 'Succeed!';\n-\t\t\t\t\t\t\tthis.className = this.className.replace('danger','');\n-\t\t\t\t\t\t}\n-\t\t\t\t\t\tf.style.animation = null;\n-\t\t\t\t\t\tf.className = f.className.replace('hourglass',c);\n-\t\t\t\t\t\tiNotify(aAddon, aMsg, aResult => {\n-\t\t\t\t\t\t\toFile.remove(!1);\n-\n-\t\t\t\t\t\t\tif(aResult !== null && aAddon && aAddon.pendingOperations) {\n-\t\t\t\t\t\t\t\tlet m = aAddon.name + ' requires restart.\\n\\n'\n-\t\t\t\t\t\t\t\t\t+ 'Would you like to restart '\n-\t\t\t\t\t\t\t\t\t+ Services.appinfo.name + ' now?';\n-\n-\t\t\t\t\t\t\t\tm = Services.prompt.confirmEx(null,\n-\t\t\t\t\t\t\t\t\taddon.name,m,1027,0,0,0,null,{});\n-\n-\t\t\t\t\t\t\t\tif(!m) {\n-\t\t\t\t\t\t\t\t\tlet cancelQuit = Cc[\"@mozilla.org/supports-PRBool;1\"]\n-\t\t\t\t\t\t\t\t\t\t.createInstance(Ci.nsISupportsPRBool);\n-\n-\t\t\t\t\t\t\t\t\tServices.obs.notifyObservers(cancelQuit,\n-\t\t\t\t\t\t\t\t\t\t\"quit-application-requested\", null);\n-\n-\t\t\t\t\t\t\t\t\tif(!cancelQuit.data) {\n-\t\t\t\t\t\t\t\t\t\tServices.obs.notifyObservers(null,\n-\t\t\t\t\t\t\t\t\t\t\t\"quit-application-granted\", null);\n-\n-\t\t\t\t\t\t\t\t\t\tServices.startup.quit(\n-\t\t\t\t\t\t\t\t\t\t\tCi.nsIAppStartup.eAttemptQuit |\n-\t\t\t\t\t\t\t\t\t\t\tCi.nsIAppStartup.eRestart\n-\t\t\t\t\t\t\t\t\t\t);\n-\t\t\t\t\t\t\t\t\t}\n+\t\t\t\tvar btn = this;\n+\t\t\t\t\n+\t\t\t\tvar postZipWrite = function() {\n+\t\t\t\t\t\n+\t\t\t\t\tzipReader.close();\n+\t\t\t\t\tzipWriter.close();\n+\t\t\t\t\t\n+\t\t\t\t\tAddonManager.getInstallForFile(oFile,aInstall => {\n+\t\t\t\t\t\tlet done = (aMsg,aAddon) => {\n+\t\t\t\t\t\t\tlet c = 'check';\n+\t\t\t\t\t\t\tif(typeof aMsg === 'number') {\n+\t\t\t\t\t\t\t\tl.textContent = 'Error ' + aMsg;\n+\t\t\t\t\t\t\t\taMsg = 'Installation failed ('+aMsg+')';\n+\t\t\t\t\t\t\t\tc = 'alert';\n+\t\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\t\tif (!btn.hasAttribute('filepath')) {\n+\t\t\t\t\t\t\t\t\tl.textContent = 'Succeed!';\n+\t\t\t\t\t\t\t\t\tbtn.className = btn.className.replace('danger','');\n+\t\t\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\t\t\t//it is uncommited file install so allow reclicking of button\n+\t\t\t\t\t\t\t\t\tl.textContent = 'Installed with Uncommitted File - Reinstall';\n+\t\t\t\t\t\t\t\t\tbtn.classList.remove('danger');\n+\t\t\t\t\t\t\t\t\tbtn.classList.remove('disabled');\n+\t\t\t\t\t\t\t\t\tbtn.removeAttribute(addon.tag); //so allows reinstall\n \t\t\t\t\t\t\t\t}\n \t\t\t\t\t\t\t}\n-\t\t\t\t\t\t});\n-\t\t\t\t\t};\n+\t\t\t\t\t\t\tf.style.animation = null;\n+\t\t\t\t\t\t\tf.className = f.className.replace('hourglass',c);\n+\t\t\t\t\t\t\tiNotify(aAddon, aMsg, aResult => {\n+\t\t\t\t\t\t\t\tOS.File.remove(oFile.path);\n+\n+\t\t\t\t\t\t\t\tif(aResult !== null && aAddon && aAddon.pendingOperations) {\n+\t\t\t\t\t\t\t\t\tlet m = aAddon.name + ' requires restart.\\n\\n'\n+\t\t\t\t\t\t\t\t\t\t+ 'Would you like to restart '\n+\t\t\t\t\t\t\t\t\t\t+ Services.appinfo.name + ' now?';\n+\n+\t\t\t\t\t\t\t\t\tm = Services.prompt.confirmEx(null,\n+\t\t\t\t\t\t\t\t\t\taddon.name,m,1027,0,0,0,null,{});\n+\n+\t\t\t\t\t\t\t\t\tif(!m) {\n+\t\t\t\t\t\t\t\t\t\tlet cancelQuit = Cc[\"@mozilla.org/supports-PRBool;1\"]\n+\t\t\t\t\t\t\t\t\t\t\t.createInstance(Ci.nsISupportsPRBool);\n+\n+\t\t\t\t\t\t\t\t\t\tServices.obs.notifyObservers(cancelQuit,\n+\t\t\t\t\t\t\t\t\t\t\t\"quit-application-requested\", null);\n+\n+\t\t\t\t\t\t\t\t\t\tif(!cancelQuit.data) {\n+\t\t\t\t\t\t\t\t\t\t\tServices.obs.notifyObservers(null,\n+\t\t\t\t\t\t\t\t\t\t\t\t\"quit-application-granted\", null);\n+\n+\t\t\t\t\t\t\t\t\t\t\tServices.startup.quit(\n+\t\t\t\t\t\t\t\t\t\t\t\tCi.nsIAppStartup.eAttemptQuit |\n+\t\t\t\t\t\t\t\t\t\t\t\tCi.nsIAppStartup.eRestart\n+\t\t\t\t\t\t\t\t\t\t\t);\n+\t\t\t\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t});\n+\t\t\t\t\t\t};\n \n-\t\t\t\t\taInstall.addListener({\n-\t\t\t\t\t\tonInstallFailed : function(aInstall) {\n-\t\t\t\t\t\t\taInstall.removeListener(this);\n+\t\t\t\t\t\taInstall.addListener({\n+\t\t\t\t\t\t\tonInstallFailed : function(aInstall) {\n+\t\t\t\t\t\t\t\taInstall.removeListener(this);\n \n-\t\t\t\t\t\t\tdone(aInstall.error);\n-\t\t\t\t\t\t},\n-\t\t\t\t\t\tonInstallEnded : function(aInstall,aAddon) {\n-\t\t\t\t\t\t\taInstall.removeListener(this);\n+\t\t\t\t\t\t\t\tdone(aInstall.error);\n+\t\t\t\t\t\t\t},\n+\t\t\t\t\t\t\tonInstallEnded : function(aInstall,aAddon) {\n+\t\t\t\t\t\t\t\taInstall.removeListener(this);\n \n-\t\t\t\t\t\t\tdone(aAddon.name + ' ' + aAddon.version\n-\t\t\t\t\t\t\t\t+ ' has been installed successfully.',aAddon);\n-\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t\tdone(aAddon.name + ' ' + aAddon.version\n+\t\t\t\t\t\t\t\t\t+ ' has been installed successfully.',aAddon);\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t});\n+\t\t\t\t\t\taInstall.install();\n \t\t\t\t\t});\n-\t\t\t\t\taInstall.install();\n-\t\t\t\t});\n \n-\t\t\t\tnFile.remove(!1);\n+\t\t\t\t\tOS.File.remove(nFile.path);","path":"bootstrap.js","position":208,"original_position":208,"commit_id":"3319dcf00714411b4166a6a1be56853bf1159c7e","original_commit_id":"3319dcf00714411b4166a6a1be56853bf1159c7e","user":{"login":"diegocr","id":734313,"avatar_url":"https://avatars.githubusercontent.com/u/734313?","gravatar_id":"cddab2145542b517d2aa87f9f8a1f813","url":"https://api.github.com/users/diegocr","html_url":"https://github.com/diegocr","followers_url":"https://api.github.com/users/diegocr/followers","following_url":"https://api.github.com/users/diegocr/following{/other_user}","gists_url":"https://api.github.com/users/diegocr/gists{/gist_id}","starred_url":"https://api.github.com/users/diegocr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diegocr/subscriptions","organizations_url":"https://api.github.com/users/diegocr/orgs","repos_url":"https://api.github.com/users/diegocr/repos","events_url":"https://api.github.com/users/diegocr/events{/privacy}","received_events_url":"https://api.github.com/users/diegocr/received_events","type":"User","site_admin":false},"body":"On this case since we've already a nsIFile instance \"locked\" it makes no sense using it to pass his path to OS.File, it's overkill.\r\n","created_at":"2014-04-27T22:54:44Z","updated_at":"2014-04-27T22:54:44Z","html_url":"https://github.com/diegocr/GitHubExtIns/pull/10#discussion_r12031923","pull_request_url":"https://api.github.com/repos/diegocr/GitHubExtIns/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/diegocr/GitHubExtIns/pulls/comments/12031923"},"html":{"href":"https://github.com/diegocr/GitHubExtIns/pull/10#discussion_r12031923"},"pull_request":{"href":"https://api.github.com/repos/diegocr/GitHubExtIns/pulls/10"}}}}