Browse Source

Hotfix 7.0

deadmoon 4 years ago
parent
commit
5d512f54c4
8 changed files with 4936 additions and 4922 deletions
  1. 4 0
      CHANGELOG.md
  2. 17 12
      Optimizer/CleanHelper.cs
  3. 1 1
      Optimizer/ErrorLogger.cs
  4. 3 3
      Optimizer/InfoForm.Designer.cs
  5. 4892 4892
      Optimizer/MainForm.Designer.cs
  6. 15 10
      Optimizer/MainForm.cs
  7. 3 3
      README.md
  8. 1 1
      version.txt

+ 4 - 0
CHANGELOG.md

@@ -2,6 +2,10 @@
 
 All notable changes to this project will be documented in this file.
 
+## [7.0] - 2021-04-08
+- New: Check space to be freed before cleaning
+- Hotfix: Error handling when HOSTS file is unreadable
+
 ## [6.9] - 2021-04-03
 - New: Added MEGAsync in Common Apps
 - Moved: Disable Silent App Install to Disable Automatic Updates

+ 17 - 12
Optimizer/CleanHelper.cs

@@ -1,6 +1,8 @@
 using System;
 using System.IO;
+using System.Linq;
 using System.Runtime.InteropServices;
+using System.Threading.Tasks;
 
 namespace Optimizer
 {
@@ -17,7 +19,6 @@ namespace Optimizer
         internal static readonly string ProfileAppDataLocalLow = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low";
         internal static readonly string OSDrive = System32Folder.Substring(0, 3);
         internal static readonly string OSDriveWindows = Environment.GetEnvironmentVariable("WINDIR", EnvironmentVariableTarget.Machine);
-        internal static readonly string UTorrentCache = ProfileAppDataRoaming + "\\uTorrent\\dlimagecache";
 
         internal static void EmptyFolder(string path)
         {
@@ -55,12 +56,7 @@ namespace Optimizer
         internal static void CleanTemporaries()
         {
             EmptyFolder(TempFolder);
-        }
-
-        internal static void CleanUTorrent()
-        {
-            EmptyFolder(UTorrentCache);
-        }
+        } 
 
         internal static void CleanFileZilla()
         {
@@ -88,11 +84,6 @@ namespace Optimizer
             EmptyFolder(ProgramData + "\\Microsoft\\Windows\\WER\\ERC");
         }
 
-        internal static void CleanPrefetch()
-        {
-            EmptyFolder(OSDriveWindows + "\\Prefetch");
-        }
-
         internal static void CleanMediaPlayersCache()
         {
             EmptyFolder(ProfileAppDataLocal + "\\Microsoft\\Media Player");
@@ -111,5 +102,19 @@ namespace Optimizer
             EmptyFolder(System32Folder + "\\LogFiles");
             EmptyFolder(OSDrive + "\\inetpub\\logs\\LogFiles");
         }
+
+        internal static ByteSize CheckFootprint()
+        {
+            try
+            {
+                DirectoryInfo info = new DirectoryInfo(TempFolder);
+                return ByteSize.FromBytes(info.EnumerateFiles("*", SearchOption.AllDirectories).Sum(file => file.Length));
+            }
+            catch (Exception ex)
+            {
+                ErrorLogger.LogError("CleanHelper.CleanLogs", ex.Message, ex.StackTrace);
+                return ByteSize.FromBytes(0);
+            }
+        }
     }
 }

+ 1 - 1
Optimizer/ErrorLogger.cs

@@ -15,7 +15,7 @@ namespace Optimizer
         {
             try
             {
-                File.AppendAllText(ErrorLogFile, string.Format("[ERROR] in function [{0}]", functionName));
+                File.AppendAllText(ErrorLogFile, string.Format("[ERROR] [{0}] in function [{1}]", DateTime.Now.ToString(), functionName));
                 File.AppendAllText(ErrorLogFile, Environment.NewLine);
                 File.AppendAllText(ErrorLogFile, errorMessage);
                 File.AppendAllText(ErrorLogFile, Environment.NewLine);

+ 3 - 3
Optimizer/InfoForm.Designer.cs

@@ -42,7 +42,7 @@
             this.btnOK.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
             this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.btnOK.ForeColor = System.Drawing.Color.White;
-            this.btnOK.Location = new System.Drawing.Point(487, 354);
+            this.btnOK.Location = new System.Drawing.Point(534, 477);
             this.btnOK.Margin = new System.Windows.Forms.Padding(2);
             this.btnOK.Name = "btnOK";
             this.btnOK.Size = new System.Drawing.Size(96, 31);
@@ -67,7 +67,7 @@
             this.txtInfo.Name = "txtInfo";
             this.txtInfo.ReadOnly = true;
             this.txtInfo.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-            this.txtInfo.Size = new System.Drawing.Size(572, 331);
+            this.txtInfo.Size = new System.Drawing.Size(619, 454);
             this.txtInfo.TabIndex = 33;
             this.txtInfo.Text = "Integrator InfoBox";
             // 
@@ -78,7 +78,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
             this.CancelButton = this.btnOK;
-            this.ClientSize = new System.Drawing.Size(593, 394);
+            this.ClientSize = new System.Drawing.Size(640, 517);
             this.Controls.Add(this.txtInfo);
             this.Controls.Add(this.btnOK);
             this.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

File diff suppressed because it is too large
+ 4892 - 4892
Optimizer/MainForm.Designer.cs


+ 15 - 10
Optimizer/MainForm.cs

@@ -329,6 +329,7 @@ namespace Optimizer
             CheckForIllegalCrossThreadCalls = false;
             Options.ApplyTheme(this);
 
+            // fix SSL/TLS error when contacting internet
             ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
 
             // initial states
@@ -408,6 +409,14 @@ namespace Optimizer
             }
 
             GetFeed();
+
+            GetFootprint();
+        }
+
+        private void GetFootprint()
+        {
+            ByteSize footprint = CleanHelper.CheckFootprint();
+            lblFootprint.Text = footprint.ToString();
         }
 
         private void GetFeed()
@@ -478,10 +487,6 @@ namespace Optimizer
                 {
                     CleanHelper.CleanTemporaries();
                 }
-                if (checkUTorrent.Checked)
-                {
-                    CleanHelper.CleanUTorrent();
-                }
                 if (checkFileZilla.Checked)
                 {
                     CleanHelper.CleanFileZilla();
@@ -490,10 +495,6 @@ namespace Optimizer
                 {
                     CleanHelper.CleanMiniDumps();
                 }
-                if (checkPrefetch.Checked)
-                {
-                    CleanHelper.CleanPrefetch();
-                }
                 if (checkMediaCache.Checked)
                 {
                     CleanHelper.CleanMediaPlayersCache();
@@ -518,6 +519,7 @@ namespace Optimizer
             finally
             {
                 CleaningAnimation(false);
+                GetFootprint();
             }
         }
 
@@ -829,10 +831,8 @@ namespace Optimizer
         private void checkSelectAll_CheckedChanged(object sender, EventArgs e)
         {
             checkTemp.Checked = checkSelectAll.Checked;
-            checkUTorrent.Checked = checkSelectAll.Checked;
             checkFileZilla.Checked = checkSelectAll.Checked;
             checkMiniDumps.Checked = checkSelectAll.Checked;
-            checkPrefetch.Checked = checkSelectAll.Checked;
             checkMediaCache.Checked = checkSelectAll.Checked;
             checkLogs.Checked = checkSelectAll.Checked;
             checkBin.Checked = checkSelectAll.Checked;
@@ -2346,5 +2346,10 @@ namespace Optimizer
 
 
         }
+
+        private void btnCheckFootprint_Click(object sender, EventArgs e)
+        {
+            CleanHelper.CheckFootprint();
+        }
     }
 }

+ 3 - 3
README.md

@@ -48,6 +48,6 @@ https://github.com/hellzerg/optimizer/blob/master/LEGACY.md
 
 ## Details: ##
 
-* Latest version: 6.9
-* Released: April 3, 2021
-* SHA256: 67B6D9E3A641C098373F6E13B3109E53134C2DAABCAE25B9C584C1BB9BAB2160
+* Latest version: 7.0
+* Released: April 8, 2021
+* SHA256: 15837AF825911C5D44116245C2B3C8545DFA700B36EA1A92EA2B91D151847FCA

+ 1 - 1
version.txt

@@ -1 +1 @@
-6.9
+7.0

Some files were not shown because too many files changed in this diff