From acc3a760c38320c70cc23ab7f9d8d6aeb7a31dff Mon Sep 17 00:00:00 2001 From: Muhammad Danish Date: Thu, 13 Apr 2023 10:27:19 +0500 Subject: [PATCH] Update cache command to handle directories --- src/WingetCreateCLI/Commands/CacheCommand.cs | 20 +++++++++++++++++++ .../Properties/Resources.Designer.cs | 13 +++++++++++- src/WingetCreateCLI/Properties/Resources.resx | 5 +++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/WingetCreateCLI/Commands/CacheCommand.cs b/src/WingetCreateCLI/Commands/CacheCommand.cs index 12deb1e2..6518cd51 100644 --- a/src/WingetCreateCLI/Commands/CacheCommand.cs +++ b/src/WingetCreateCLI/Commands/CacheCommand.cs @@ -69,6 +69,17 @@ public override Task Execute() file.Delete(); } + Console.WriteLine(); + var directories = dir.GetDirectories(); + Logger.InfoLocalized(nameof(Resources.DirectoriesFound_Message), directories.Length, PackageParser.InstallerDownloadPath); + Console.WriteLine(); + + foreach (DirectoryInfo directory in directories) + { + Logger.WarnLocalized(nameof(Resources.DeletingInstaller_Message), directory.Name + Path.DirectorySeparatorChar); + directory.Delete(true); + } + Console.WriteLine(); Logger.InfoLocalized(nameof(Resources.InstallerCacheCleaned_Message)); } @@ -82,6 +93,15 @@ public override Task Execute() { Logger.Debug(Path.GetFileName(file)); } + + Console.WriteLine(); + string[] directories = Directory.GetDirectories(PackageParser.InstallerDownloadPath); + Logger.InfoLocalized(nameof(Resources.DirectoriesFound_Message), directories.Length, PackageParser.InstallerDownloadPath); + Console.WriteLine(); + foreach (string directory in directories) + { + Logger.Debug(Path.GetRelativePath(PackageParser.InstallerDownloadPath, directory) + Path.DirectorySeparatorChar); + } } else if (this.Open) { diff --git a/src/WingetCreateCLI/Properties/Resources.Designer.cs b/src/WingetCreateCLI/Properties/Resources.Designer.cs index 67803ba4..ee873e0b 100644 --- a/src/WingetCreateCLI/Properties/Resources.Designer.cs +++ b/src/WingetCreateCLI/Properties/Resources.Designer.cs @@ -455,7 +455,18 @@ public static string DetectedArchMismatch_Message { return ResourceManager.GetString("DetectedArchMismatch_Message", resourceCulture); } } - + + /// + /// Looks up a localized string similar to {0} directories found in {1}. + /// + public static string DirectoriesFound_Message + { + get + { + return ResourceManager.GetString("DirectoriesFound_Message", resourceCulture); + } + } + /// /// Looks up a localized string similar to Would you like to discard this update and start over?. /// diff --git a/src/WingetCreateCLI/Properties/Resources.resx b/src/WingetCreateCLI/Properties/Resources.resx index 66b249fb..bbae383b 100644 --- a/src/WingetCreateCLI/Properties/Resources.resx +++ b/src/WingetCreateCLI/Properties/Resources.resx @@ -167,6 +167,11 @@ The full package description + + {0} directories found in {1} + {0} - Will be replaced with the number of directories found in the cache folder +{1} - Will be replaced with the path to the cache folder + DONE