From 069fb6b05bf3fc3a8b945ce0bd7b882b2435127d Mon Sep 17 00:00:00 2001 From: ivenovalue Date: Thu, 11 Feb 2016 17:09:56 +0100 Subject: [PATCH 1/3] Fixed installer for Discord, PTB, Canary --- .../BetterDiscordWI/panels/Panel1.Designer.cs | 20 +- .../BetterDiscordWI/panels/Panel1.cs | 175 +++--------- .../BetterDiscordWI/panels/Panel2.cs | 254 ++++++------------ WindowsInstaller/dlls/asardotnet.dll | Bin 8704 -> 8704 bytes 4 files changed, 129 insertions(+), 320 deletions(-) diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs index 31ddf84b..1f37864f 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs @@ -31,11 +31,11 @@ this.label1 = new System.Windows.Forms.Label(); this.btnBrowser = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); - this.tbPath = new BetterDiscordWI.components.CTextBox(); this.label3 = new System.Windows.Forms.Label(); this.cbRestart = new System.Windows.Forms.CheckBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.tbPath = new BetterDiscordWI.components.CTextBox(); this.SuspendLayout(); // // label1 @@ -67,15 +67,6 @@ this.label2.TabIndex = 3; this.label2.Text = "*If the path is not pointing to the latest version of Discord then click browse a" + "nd select it."; - // - // tbPath - // - this.tbPath.CAutoSize = false; - this.tbPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbPath.Location = new System.Drawing.Point(23, 46); - this.tbPath.Name = "tbPath"; - this.tbPath.Size = new System.Drawing.Size(377, 26); - this.tbPath.TabIndex = 4; // // label3 // @@ -119,6 +110,15 @@ this.checkBox2.UseVisualStyleBackColor = true; this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); // + // tbPath + // + this.tbPath.CAutoSize = false; + this.tbPath.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbPath.Location = new System.Drawing.Point(23, 46); + this.tbPath.Name = "tbPath"; + this.tbPath.Size = new System.Drawing.Size(377, 26); + this.tbPath.TabIndex = 4; + // // Panel1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs index 8106ffe7..6a0ae883 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs @@ -3,17 +3,13 @@ using System.Diagnostics; using System.IO; using System.Windows.Forms; -namespace BetterDiscordWI.panels -{ - public partial class Panel1 : UserControl, IPanel - { - public Panel1() - { +namespace BetterDiscordWI.panels { + public partial class Panel1: UserControl, IPanel { + public Panel1() { InitializeComponent(); } - public void SetVisible() - { + public void SetVisible() { GetParent().btnBack.Visible = true; GetParent().btnNext.Enabled = true; @@ -21,134 +17,69 @@ namespace BetterDiscordWI.panels GetParent().btnNext.Text = "Install"; GetParent().lblPanelTitle.Text = "BetterDiscord Installation"; - String[] directories = Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Discord"); - - String highestVersion = null; - - foreach(String s in directories) - { - Debug.Print(s); - if (!s.Contains("app-")) continue; - if (String.IsNullOrEmpty(highestVersion)) - { - highestVersion = s; - continue; - } - - if (String.CompareOrdinal(s, highestVersion) > 0) - { - highestVersion = s; - } - } - - - tbPath.Text = highestVersion; + pickVersion(); } - public FormMain GetParent() - { - return (FormMain) ParentForm; + public FormMain GetParent() { + return (FormMain)ParentForm; } - public void BtnNext() - { + public void BtnNext() { GetParent().DiscordPath = tbPath.Text; GetParent().RestartDiscord = cbRestart.Checked; GetParent().SwitchPanel(2); } - public void BtnPrev() - { + public void BtnPrev() { GetParent().SwitchPanel(0); } - private void btnBrowser_Click(object sender, EventArgs e) - { - FolderBrowserDialog fbd = new FolderBrowserDialog {SelectedPath = tbPath.Text}; + private void btnBrowser_Click(object sender, EventArgs e) { + FolderBrowserDialog fbd = new FolderBrowserDialog { SelectedPath = tbPath.Text }; fbd.ShowDialog(GetParent()); tbPath.Text = fbd.SelectedPath; } - private void checkBox1_CheckedChanged(object sender, EventArgs e) - { - if (checkBox1.Checked == true) - { - checkBox2.Checked = false; - String[] directories = Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\DiscordCanary"); - - String highestVersion = null; - - foreach (String s in directories) - { - Debug.Print(s); - if (!s.Contains("app-")) continue; - if (String.IsNullOrEmpty(highestVersion)) - { - highestVersion = s; - continue; - } - - if (String.CompareOrdinal(s, highestVersion) > 0) - { - highestVersion = s; - } - } - - - tbPath.Text = highestVersion; - } - if (checkBox1.Checked == false) - { - if (checkBox2.Checked == false) - { - String[] directories = Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Discord"); - - String highestVersion = null; - - foreach (String s in directories) - { - Debug.Print(s); - if (!s.Contains("app-")) continue; - if (String.IsNullOrEmpty(highestVersion)) - { - highestVersion = s; - continue; - } - - if (String.CompareOrdinal(s, highestVersion) > 0) - { - highestVersion = s; - } - } - - - tbPath.Text = highestVersion; - } - } + private void checkBox1_CheckedChanged(object sender, EventArgs e) { + pickVersion(); } - private void checkBox2_CheckedChanged(object sender, EventArgs e) - { - if (checkBox2.Checked == true) - { + private void checkBox2_CheckedChanged(object sender, EventArgs e) { + pickVersion(); + } + + private void pickVersion() { + string dirPath = null; + if(checkBox1.Checked == true) { + dirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\DiscordCanary"; + if(!Directory.Exists(dirPath)) checkBox1.Checked = false; + + checkBox2.Checked = false; + } else if(checkBox2.Checked == true) { + dirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\DiscordPTB"; + if(!Directory.Exists(dirPath)) checkBox2.Checked = false; + checkBox1.Checked = false; - String[] directories = Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\DiscordPTB"); + } else { + dirPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Discord"; + } + + if(Directory.Exists(dirPath)) { + String[] directories = Directory.GetDirectories(dirPath); String highestVersion = null; - foreach (String s in directories) - { + foreach(String s in directories) { Debug.Print(s); - if (!s.Contains("app-")) continue; - if (String.IsNullOrEmpty(highestVersion)) - { + if(!s.Contains("app-")) + continue; + if(String.IsNullOrEmpty(highestVersion)) { highestVersion = s; continue; } - if (String.CompareOrdinal(s, highestVersion) > 0) - { + if(String.CompareOrdinal(s, highestVersion) > 0) { highestVersion = s; } } @@ -156,34 +87,6 @@ namespace BetterDiscordWI.panels tbPath.Text = highestVersion; } - if (checkBox2.Checked == false) - { - if (checkBox1.Checked == false) - { - String[] directories = Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Discord"); - - String highestVersion = null; - - foreach (String s in directories) - { - Debug.Print(s); - if (!s.Contains("app-")) continue; - if (String.IsNullOrEmpty(highestVersion)) - { - highestVersion = s; - continue; - } - - if (String.CompareOrdinal(s, highestVersion) > 0) - { - highestVersion = s; - } - } - - - tbPath.Text = highestVersion; - } - } } } } diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs index e4b81b11..173f47ca 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs @@ -9,20 +9,16 @@ using System.Threading; using System.Windows.Forms; using asardotnet; -namespace BetterDiscordWI.panels -{ - public partial class Panel2 : UserControl, IPanel - { +namespace BetterDiscordWI.panels { + public partial class Panel2: UserControl, IPanel { private String _dataPath, _tempPath; private Utils _utils; - public Panel2() - { + public Panel2() { InitializeComponent(); } - public void SetVisible() - { + public void SetVisible() { GetParent().btnBack.Enabled = false; GetParent().btnNext.Enabled = false; GetParent().btnBack.Visible = false; @@ -30,74 +26,56 @@ namespace BetterDiscordWI.panels GetParent().btnCancel.Enabled = false; _utils = new Utils(); - if (GetParent().DiscordPath.Contains("Discord\\")) - { - AppendLog("Killing Discord"); - foreach (var process in Process.GetProcessesByName("Discord")) - { - process.Kill(); - } - } - if (GetParent().DiscordPath.Contains("DiscordCanary\\")) - { - AppendLog("Killing DiscordCanary"); - foreach (var process in Process.GetProcessesByName("DiscordCanary")) - { - process.Kill(); - } - } - if (GetParent().DiscordPath.Contains("DiscordPTB\\")) - { - AppendLog("Killing DiscordPTB"); - foreach (var process in Process.GetProcessesByName("DiscordPTB")) - { - process.Kill(); - } - } + + KillProcessIfInstalling("Discord"); + KillProcessIfInstalling("DiscordCanary"); + KillProcessIfInstalling("DiscordPTB"); CreateDirectories(); } - private void CreateDirectories() - { - Thread t = new Thread(() => - { + private void KillProcessIfInstalling(string app) { + if(GetParent().DiscordPath.Contains(app + "\\")) { + AppendLog("Killing " + app); + foreach(var process in Process.GetProcessesByName(app)) { + process.Kill(); + } + } + } + + private void CreateDirectories() { + Thread t = new Thread(() => { _dataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord"; _tempPath = _dataPath + "\\temp"; AppendLog("Deleting old cached files"); - try - { - if (File.Exists(_dataPath + "\\emotes_bttv.json")) - { + try { + if(File.Exists(_dataPath + "\\emotes_bttv.json")) { File.Delete(_dataPath + "\\emotes_bttv.json"); } - if (File.Exists(_dataPath + "\\emotes_bttv_2.json")) - { + if(File.Exists(_dataPath + "\\emotes_bttv_2.json")) { File.Delete(_dataPath + "\\emotes_bttv_2.json"); } - if (File.Exists(_dataPath + "\\emotes_ffz.json")) { + if(File.Exists(_dataPath + "\\emotes_ffz.json")) { File.Delete(_dataPath + "\\emotes_ffz.json"); } - if (File.Exists(_dataPath + "\\emotes_twitch_global.json")) { + if(File.Exists(_dataPath + "\\emotes_twitch_global.json")) { File.Delete(_dataPath + "\\emotes_twitch_global.json"); } - if (File.Exists(_dataPath + "\\emotes_twitch_subscriber.json")) { + if(File.Exists(_dataPath + "\\emotes_twitch_subscriber.json")) { File.Delete(_dataPath + "\\emotes_twitch_subscriber.json"); } - if (File.Exists(_dataPath + "\\user.json")) { + if(File.Exists(_dataPath + "\\user.json")) { File.Delete(_dataPath + "\\user.json"); } - } catch (Exception e) { AppendLog("Failed to delete one or more cached files"); } + } catch(Exception e) { AppendLog("Failed to delete one or more cached files"); } - if (Directory.Exists(_tempPath)) - { + if(Directory.Exists(_tempPath)) { AppendLog("Deleting temp path"); Directory.Delete(_tempPath, true); } - while (Directory.Exists(_tempPath)) - { + while(Directory.Exists(_tempPath)) { Debug.Print("Waiting for dirdel"); Thread.Sleep(100); } @@ -106,8 +84,7 @@ namespace BetterDiscordWI.panels DownloadResource("BetterDiscord.zip", "https://github.com/Jiiks/BetterDiscordApp/archive/stable.zip"); - while (!File.Exists(_tempPath + "\\BetterDiscord.zip")) - { + while(!File.Exists(_tempPath + "\\BetterDiscord.zip")) { Debug.Print("Waiting for download"); Thread.Sleep(100); } @@ -127,30 +104,23 @@ namespace BetterDiscordWI.panels } - private void DeleteDirs() - { + private void DeleteDirs() { int errors = 0; - Thread t = new Thread(() => - { + Thread t = new Thread(() => { String dir = GetParent().DiscordPath + "\\resources\\app"; - if (Directory.Exists(dir)) - { - try - { + if(Directory.Exists(dir)) { + try { AppendLog("Deleting " + dir); Directory.Delete(dir, true); - } - catch - { + } catch { AppendLog("Error Failed to Delete the '" + dir + "\\resources\\app' Directory."); errors = 1; Finalize(errors); } } - while (Directory.Exists(dir)) - { + while(Directory.Exists(dir)) { Debug.Print("Waiting for direl"); Thread.Sleep(100); } @@ -158,14 +128,12 @@ namespace BetterDiscordWI.panels dir = GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord"; - if (Directory.Exists(dir)) - { + if(Directory.Exists(dir)) { AppendLog("Deleting " + dir); Directory.Delete(dir, true); } - while (Directory.Exists(dir)) - { + while(Directory.Exists(dir)) { Debug.Print("Waiting for direl"); Thread.Sleep(100); } @@ -174,107 +142,59 @@ namespace BetterDiscordWI.panels Directory.Move(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\BetterDiscordApp-stable", GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord"); - try - { + try { AppendLog("Extracting app.asar"); AsarArchive archive = new AsarArchive(GetParent().DiscordPath + "\\resources\\app.asar"); AsarExtractor extractor = new AsarExtractor(); //Add extraoffset of 3 - extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\", 3); + extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\"); Splice(); - } - catch - { + } catch { AppendLog("Error Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue."); errors = 1; Finalize(errors); } }); - - + + t.Start(); } - private void DownloadResource(String resource, String url) - { + private void DownloadResource(String resource, String url) { AppendLog("Downloading Resource: " + resource); WebClient webClient = new WebClient(); webClient.Headers["User-Agent"] = "Mozilla/5.0"; - + webClient.DownloadFile(new Uri(url), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\" + resource); } - private void Splice() - { + private void Splice() { String indexloc = GetParent().DiscordPath + "\\resources\\app\\app\\index.js"; - Thread t = new Thread(() => - { + Thread t = new Thread(() => { List lines = new List(); AppendLog("Spicing index"); - using (FileStream fs = new FileStream(indexloc, FileMode.Open)) - { - using (StreamReader reader = new StreamReader(fs)) - { + using(FileStream fs = new FileStream(indexloc, FileMode.Open)) { + using(StreamReader reader = new StreamReader(fs)) { String line = ""; - while((line = reader.ReadLine()) != null) - { - if (GetParent().DiscordPath.Contains("Discord\\")) - { - if (line.Contains("var _discord_overlay2")) - { - lines.Add(line); - lines.Add("var _betterDiscord = require('betterdiscord');"); - } - else if (line.Contains("mainWindow = new _electron.BrowserWindow")) - { - lines.Add(line); - lines.Add(File.ReadAllText("splice")); - } - else - { - lines.Add(line); - } - } - if (GetParent().DiscordPath.Contains("DiscordCanary\\")) - { - if (line.Contains("var _discord_overlay2")) - { - lines.Add(line); - lines.Add("var _betterDiscord = require('betterdiscord');"); - } - else if (line.Contains("mainWindow = new _BrowserWindow2")) - { - lines.Add(line); - lines.Add(File.ReadAllText("splice")); - } - else - { - lines.Add(line); - } - } - if (GetParent().DiscordPath.Contains("DiscordPTB\\")) - { - if (line.Contains("var _discord_overlay2")) - { - lines.Add(line); - lines.Add("var _betterDiscord = require('betterdiscord');"); - } - //"mainWindow = new _browserWindow2" was changed in DiscordPTB v0.0.6 - else if (line.Contains("mainWindow = new _electron.BrowserWindow")) - { - lines.Add(line); - lines.Add(File.ReadAllText("splice")); - } - else - { - lines.Add(line); - } + while((line = reader.ReadLine()) != null) { + //if(GetParent().DiscordPath.Contains("Discord\\")) { + //if(GetParent().DiscordPath.Contains("DiscordCanary\\")) { + //if(GetParent().DiscordPath.Contains("DiscordPTB\\")) { + if(line.Replace(" ", "").Contains("var_fs=")) { + lines.Add(line); + lines.Add("var _betterDiscord = require('betterdiscord');"); + } else if(line.Replace(" ", "").Contains("mainWindow=new")) { + lines.Add(line); + lines.Add(File.ReadAllText("splice")); + } else { + lines.Add(line); } + //} } } } @@ -283,33 +203,30 @@ namespace BetterDiscordWI.panels File.WriteAllLines(indexloc, lines.ToArray()); - + AppendLog("Finished installation, verifying installation..."); int errors = 0; String curPath = GetParent().DiscordPath + "\\resources\\app\\app\\index.js"; - - if (!File.Exists(curPath)) - { + + if(!File.Exists(curPath)) { AppendLog("ERROR: FILE: " + curPath + " DOES NOT EXIST!"); errors++; } curPath = GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord"; - if (!Directory.Exists(curPath)) - { + if(!Directory.Exists(curPath)) { AppendLog("ERROR: DIRECTORY: " + curPath + " DOES NOT EXIST"); errors++; } String basePath = GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord"; - String[] bdFiles = {"\\package.json", "\\betterdiscord.js", "\\lib\\BetterDiscord.js", "\\lib\\config.json", "\\lib\\Utils.js"}; + String[] bdFiles = { "\\package.json", "\\betterdiscord.js", "\\lib\\BetterDiscord.js", "\\lib\\config.json", "\\lib\\Utils.js" }; - foreach (string s in bdFiles.Where(s => !File.Exists(basePath + s))) - { + foreach(string s in bdFiles.Where(s => !File.Exists(basePath + s))) { AppendLog("ERROR: FILE: " + basePath + s + " DOES NOT EXIST"); errors++; } @@ -321,59 +238,48 @@ namespace BetterDiscordWI.panels t.Start(); } - private void Finalize(int errors) - { + private void Finalize(int errors) { AppendLog("Finished installing BetterDiscord with " + errors + " errors"); - Invoke((MethodInvoker) delegate - { + Invoke((MethodInvoker)delegate { GetParent().finished = true; GetParent().btnCancel.Text = "OK"; GetParent().btnCancel.Enabled = true; }); - if (GetParent().RestartDiscord) - { - if (GetParent().DiscordPath.Contains("\\Discord\\")) - { + if(GetParent().RestartDiscord) { + if(GetParent().DiscordPath.Contains("\\Discord\\")) { Process.Start(GetParent().DiscordPath + "\\Discord.exe"); } - if (GetParent().DiscordPath.Contains("\\DiscordCanary\\")) - { + if(GetParent().DiscordPath.Contains("\\DiscordCanary\\")) { Process.Start(GetParent().DiscordPath + "\\DiscordCanary.exe"); } - if (GetParent().DiscordPath.Contains("\\DiscordPTB\\")) - { + if(GetParent().DiscordPath.Contains("\\DiscordPTB\\")) { Process.Start(GetParent().DiscordPath + "\\DiscordPTB.exe"); } } } - public FormMain GetParent() - { + public FormMain GetParent() { return (FormMain)ParentForm; } - public void BtnNext() - { + public void BtnNext() { throw new NotImplementedException(); } - public void BtnPrev() - { + public void BtnPrev() { throw new NotImplementedException(); } - private void AppendLog(String message) - { - Invoke((MethodInvoker) delegate - { + private void AppendLog(String message) { + Invoke((MethodInvoker)delegate { rtLog.AppendText(message + "\n"); rtLog.SelectionStart = rtLog.Text.Length; rtLog.ScrollToCaret(); }); - + } } } diff --git a/WindowsInstaller/dlls/asardotnet.dll b/WindowsInstaller/dlls/asardotnet.dll index 07158322a8977944b400963d8701073b1b41c390..baa83d40bbbfbed9342c9ab1c4745a1bfd67cd1a 100644 GIT binary patch delta 3147 zcmZWr3v3j}8UAN>XLj#=xAyKm@R>Vvws{;j7!y+r35hT^p;l*77A`~0zPs! zmB2mD2uMN`LfnM}R3h4{jd0b5R8|v6qBJyZXwssJMioj0Rii#s5-AOh(lk+t`px(N zN8QtY^MC(q{`qHi_lDbt+n;#E_~rLr9(gpy_Kb|KaWV^uvV?0fQKd0b6A5i33W0yn zLX`At_$3Fn7*Q}H0+08(q9-B)uFN1o!$ddBwMuR_aw+SC zjFEsFs47lK8gzpt?=shR%X%UqH{gc;FKO5fm)x8iC9BM?Ga*&Es><$;RJi4tD3MgP z%FHBHu*+>1YS$eILKi6rESmFgsv%=RQ{aB3(LR?b(qz&h-9B>7NrzHsUPQVwK4s3+ zuFNHnD`@0QmBaF^Ou&ECSm3{I%qqsAiq|7>a+9Dl7*UC|9;^F$u3VB9FEO1N22g>X>_`{(6+mi9lB zzb~$oM0I<>XvnNv}61+coKV9w`5!H zYvAfa&)Aw2w*%NL`gB?|p|9vYHR48ULI_pj#@VCAxMB0}v73uQ%Cftdq+_hWg7l)6 zU*n@(();`}P#6kpHMVM8t8qZ%;~GabzGM8tko1v8!&Fg8jmyo2<_g-V&Ltf-bEc%z z8ZVg_Os7apd<0cU6i~zru^CRwgi5qQ<5sQN4vf%2JQ0$9rZq2WJg4!Gz#zRZ?!p4N zREtSSwU`-N-X~Sg6Y`*xX!LWyceJL=x`26uv-Qvd^dAdkiV}^fpca~jH&l?ys0`u!Yl&T;daxbitnw1g z0ec1ym&$S#ah#qlF~K~r=SwWjl&$zmiQdOrL0=zdNOL#XKT5WptP|z!#{;U8o@SfS zo$flt_R=}F6`lI-RBc0CKfVX2#u@#A)q*`&Vt>K(Av#lHA8Ph$@n+yo7?Y-2LgBo`MkD#$C_@KrSjmLq zr;9XC{1);eXcE*a-lDhR`7vFiL2;dC(r#h0nY2#?S%`|`J9b3OVp00OSj4W;v!ay+ z*m5U>|G7pNg}z)N0^;ENji@Hnu5@H)0vx!5i@a z9{^6Kqrf_i4fG{Nnzi8$`VQnaZOCd|M`O@DKv#eR^e%9SJ_PQg|MIsf#=6-X>_4oE z-^Qo0FW_~0*iSeu3+7QHQ^(O%P`Vgh)zrWN6tK*om(bCdXg2N^a#@y6G5=dmA&~7@ zyY#DF9baDU%kqY?wdG~Z-&JvbY`MFf2eP{c279+RcC7H9igYHH^bNM<`oGbeAMDN3 z>Rdg#kpNu#Ao$*@6{CvD|&aB^bZ9BTEaQEn%oc6ji4L|Kh-DoL&DW^!QO06{ahDV)b zz%nta_9(rLw()>tBcBmKUtlr<<(9x`I{|!6p*ibcto-*1{C~e!okF~!D2am^T7bKX zXjQg7`$VF4+gC8tMf;&S{CzdwEQnK38%slkUAj=AZ7vXLh1e`UMui~s-t delta 3167 zcmY*b4{#LK8UNnf-M4$2%O<;bx#UPLxiblz2_y$W0@_yo1ZZf5&_IA1su2>1(i~h) z1_|+wu}~SsN!X&sLKzsDsZ3jJ(^g8Sj5@6?<4CRJjAh1J@Xyq-e;7y0h{Iri@7;lA zGy8kr?|a|B_ujYflJCfOj6JITaN_j%V==aT{JAyG)wx6~2+w??Ds4Ow3f@Z;1pj?I zQH`JA)BSa98e8S>X1Qo;9wzX79WN(?e$oghkBIr(rnFnNe1s9{O@0?|$UO}cFqbD? zBAaWYI;Oamgta}&r92|Bt~?2=<|O21Ths-U8iXld>PpN=G6I+24RdK=eQ8h{NLCOD zX(W=Bung&3Sb>u3$7bQ)6&Ay=>5UyFJ}!WEIa z*2AtyM-j@_((n@@(=(H{U#ZX49DS|7LZ3bpiA1ESI%UvlL_kR{AFh!rvyrFhB|MP? z6*d=1$3Ll8(%3sNQvr;t%9)h}J$*@02VYQi|}`h{E4_kqg?yUW&8a4Uebrq3JO2%U)Cq*lBLt^CnU zQcd&mBBcLkt2HO+BpoN4GHg8)^a4A?Z2Gs7x%MF!G()S_1a&CvQbdX;<%vx5F2&Imytiw}Si zQ)hu*tmvD(5z?>3Q#HZa_$>y&ZV$oT}4(w3G|l@ zJV-9^6ior1qk34qPfd`oDt!cXC8&)_o1JU{X3wzi0M9dN`Cbmwj5wF1oJ+YDC@95u zP*)sv&|dmJN@29N$PQ5j*u6#eGSz}@F0#MURIsf@_AhDy+fiUum#Gb`2A`>nX|W3Q zQ9~kEpbe}Pbb4{}PBl5Z$o8_unEOhBAk=ri6CdvUh?Ez}^I8di?rGHB4 zk0||*mHwCirRbh7QnuUG=5oMtPTOml_)CN8pdOs;Po`$GIf$ytOBnpapKt2Ms> zPBRU@jr+EwC#&VCEGk6P?&@5nxb^)u=0WJ8B zB{nN;Q~EpT05pq~rd#3NbOM?O=uO}-T?CHMN5Dtu6aIG!u;uJUc8R(CRvu+dEX(#X zJzu!0(R+o*-{UmiK9}xdlIlgJ9B>gBa@5dI24<$=2yeyPjJKT(h6@%x{=3eoKUmh3 z?0#rC+yC8`&K0y|a7%yZ&_J5*8MrPj?ayAVr0&6;{r=(d zKb7?F$Y%Oh3=9nSXD2thcX9u>p{{861A|*>;b3-AdT4upCflE(Rq4*5Y}>5KhHwq{ z7er<;=4T@H{!@_|Z4H5qXOA||U9$V#U-$g6b<4NOdSPd8PjvQ$efS?qi<6~^n4!lh zW@y4Ih2WL?pF|QVSBkEUpOlzk#SG82;yU*%$FWRN;Z-m Date: Thu, 11 Feb 2016 19:47:34 +0100 Subject: [PATCH 2/3] Check for app.asar file --- .../BetterDiscordWI/panels/Panel2.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs index 173f47ca..bae2fd2f 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs @@ -114,7 +114,7 @@ namespace BetterDiscordWI.panels { AppendLog("Deleting " + dir); Directory.Delete(dir, true); } catch { - AppendLog("Error Failed to Delete the '" + dir + "\\resources\\app' Directory."); + AppendLog("Error: Failed to Delete the '" + dir + "\\resources\\app' Directory."); errors = 1; Finalize(errors); } @@ -144,15 +144,23 @@ namespace BetterDiscordWI.panels { try { AppendLog("Extracting app.asar"); - AsarArchive archive = new AsarArchive(GetParent().DiscordPath + "\\resources\\app.asar"); + string appAsarPath = GetParent().DiscordPath + "\\resources\\app.asar"; - AsarExtractor extractor = new AsarExtractor(); - //Add extraoffset of 3 - extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\"); + if(File.Exists(appAsarPath)) { + AsarArchive archive = new AsarArchive(appAsarPath); - Splice(); + AsarExtractor extractor = new AsarExtractor(); + //Add extraoffset of 3 + extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\"); + + Splice(); + } else { + AppendLog("Error: app.asar file couldn't be found in 'resources' folder. Installation cannot Continue."); + errors = 1; + Finalize(errors); + } } catch { - AppendLog("Error Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue."); + AppendLog("Error: Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue."); errors = 1; Finalize(errors); } From bf8ab019c68c28fdf3bff6dd9668a0a010290d65 Mon Sep 17 00:00:00 2001 From: ivenovalue Date: Thu, 11 Feb 2016 20:00:33 +0100 Subject: [PATCH 3/3] Changed the sequence of actions. --- .../BetterDiscordWI/panels/Panel2.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs index bae2fd2f..84b11942 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs @@ -138,32 +138,31 @@ namespace BetterDiscordWI.panels { Thread.Sleep(100); } - AppendLog("Moving BetterDiscord to resources\\node_modules\\"); + AppendLog("Extracting app.asar"); + string appAsarPath = GetParent().DiscordPath + "\\resources\\app.asar"; - Directory.Move(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\BetterDiscordApp-stable", GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord"); + if(File.Exists(appAsarPath)) { + AsarArchive archive = new AsarArchive(appAsarPath); + AsarExtractor extractor = new AsarExtractor(); + extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\"); + } else { + AppendLog("Error: app.asar file couldn't be found in 'resources' folder. Installation cannot Continue."); + errors = 1; + Finalize(errors); + } - try { - AppendLog("Extracting app.asar"); - string appAsarPath = GetParent().DiscordPath + "\\resources\\app.asar"; - - if(File.Exists(appAsarPath)) { - AsarArchive archive = new AsarArchive(appAsarPath); - - AsarExtractor extractor = new AsarExtractor(); - //Add extraoffset of 3 - extractor.ExtractAll(archive, GetParent().DiscordPath + "\\resources\\app\\"); + if(errors == 0) { + AppendLog("Moving BetterDiscord to resources\\node_modules\\"); + Directory.Move(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\BetterDiscordApp-stable", GetParent().DiscordPath + "\\resources\\node_modules\\BetterDiscord"); + try { Splice(); - } else { - AppendLog("Error: app.asar file couldn't be found in 'resources' folder. Installation cannot Continue."); + } catch { + AppendLog("Error: Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue."); errors = 1; Finalize(errors); } - } catch { - AppendLog("Error: Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue."); - errors = 1; - Finalize(errors); - } + } });