Skip to content

Commit

Permalink
Hotfix 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hellzerg committed Apr 8, 2021
1 parent 5f6e0dc commit 5d512f5
Show file tree
Hide file tree
Showing 8 changed files with 4,938 additions and 4,924 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 17 additions & 12 deletions Optimizer/CleanHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;

namespace Optimizer
{
Expand All @@ -17,7 +19,6 @@ internal static class CleanHelper
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)
{
Expand Down Expand Up @@ -55,12 +56,7 @@ internal static void EmptyRecycleBin()
internal static void CleanTemporaries()
{
EmptyFolder(TempFolder);
}

internal static void CleanUTorrent()
{
EmptyFolder(UTorrentCache);
}
}

internal static void CleanFileZilla()
{
Expand Down Expand Up @@ -88,11 +84,6 @@ internal static void CleanErrorReports()
EmptyFolder(ProgramData + "\\Microsoft\\Windows\\WER\\ERC");
}

internal static void CleanPrefetch()
{
EmptyFolder(OSDriveWindows + "\\Prefetch");
}

internal static void CleanMediaPlayersCache()
{
EmptyFolder(ProfileAppDataLocal + "\\Microsoft\\Media Player");
Expand All @@ -111,5 +102,19 @@ internal static void CleanLogs()
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);
}
}
}
}
2 changes: 1 addition & 1 deletion Optimizer/ErrorLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static void LogError(string functionName, string errorMessage, string e
{
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);
Expand Down
6 changes: 3 additions & 3 deletions Optimizer/InfoForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5d512f5

Please sign in to comment.