From caeaad9d7655eab333f6f495a2c366fed0a68d1a Mon Sep 17 00:00:00 2001 From: Soham Das Date: Tue, 9 Apr 2024 12:24:04 -0700 Subject: [PATCH] Addressed PR comments --- .../Helpers/DevDriveCacheData.cs | 2 +- .../Strings/en-us/Resources.resw | 2 +- .../OptimizeDevDriveDialogViewModel.cs | 4 ++-- .../ViewModels/DevDriveInsightsViewModel.cs | 19 +++++++++---------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tools/Customization/DevHome.Customization/Helpers/DevDriveCacheData.cs b/tools/Customization/DevHome.Customization/Helpers/DevDriveCacheData.cs index 8fb1762a18..8b9223c3cc 100644 --- a/tools/Customization/DevHome.Customization/Helpers/DevDriveCacheData.cs +++ b/tools/Customization/DevHome.Customization/Helpers/DevDriveCacheData.cs @@ -17,5 +17,5 @@ public partial class DevDriveCacheData public List? CacheDirectory { get; set; } - public string? ExampleDirectory { get; set; } + public string? ExampleSubDirectory { get; set; } } diff --git a/tools/Customization/DevHome.Customization/Strings/en-us/Resources.resw b/tools/Customization/DevHome.Customization/Strings/en-us/Resources.resw index 51c629d08a..3914c8eb00 100644 --- a/tools/Customization/DevHome.Customization/Strings/en-us/Resources.resw +++ b/tools/Customization/DevHome.Customization/Strings/en-us/Resources.resw @@ -163,7 +163,7 @@ Example: - Example string + Example string, will be followed by a sample location to move the cache to a dev drive location End Task diff --git a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs index 509e3c776f..a87f2804bb 100644 --- a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs +++ b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs @@ -128,7 +128,7 @@ private int MoveDirectory(string sourceDirectory, string targetDirectory) catch (Exception ex) { Log.Error($"Error in MoveDirectory. Error: {ex}"); - TelemetryFactory.Get().LogError("DevDriveInsights_PackageCacheMove_Error", LogLevel.Critical, new ExceptionEvent(ex.HResult, sourceDirectory)); + TelemetryFactory.Get().LogError("DevDriveInsights_PackageCacheMoveDirectory_Error", LogLevel.Critical, new ExceptionEvent(ex.HResult, sourceDirectory)); return ex.HResult; } } @@ -173,7 +173,7 @@ private void DirectoryInputConfirmed() { SetEnvironmentVariable(EnvironmentVariableToBeSet, directoryPath); Log.Debug($"Moved cache from {ExistingCacheLocation} to {directoryPath}"); - TelemetryFactory.Get().Log("DevDriveInsights_PackageCacheMoved_Event", LogLevel.Critical, new ExceptionEvent(0, ExistingCacheLocation)); + TelemetryFactory.Get().Log("DevDriveInsights_PackageCacheMovedSuccessfully_Event", LogLevel.Critical, new ExceptionEvent(0, ExistingCacheLocation)); } } else diff --git a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs index 0ef2ac49e2..8f22618656 100644 --- a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs +++ b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs @@ -59,8 +59,6 @@ public partial class DevDriveInsightsViewModel : ObservableObject private static readonly string _userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - private const string ExampleDevDriveDirStr = "D:"; - private const string PackagesStr = "packages"; private const string CacheStr = "cache"; @@ -264,14 +262,14 @@ public void UpdateListViewModelList() Path.Join(_localAppDataPath, "pip", CacheStr), Path.Join(_localAppDataPath, PackagesStr, "PythonSoftwareFoundation.Python"), }, - ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "pip", CacheStr), + ExampleSubDirectory = Path.Join(PackagesStr, "pip", CacheStr), }, new DevDriveCacheData { CacheName = "NuGet cache (dotnet)", EnvironmentVariable = "NUGET_PACKAGES", CacheDirectory = new List { Path.Join(_userProfilePath, ".nuget", PackagesStr) }, - ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "NuGet", CacheStr), + ExampleSubDirectory = Path.Join(PackagesStr, "NuGet", CacheStr), }, new DevDriveCacheData { @@ -282,7 +280,7 @@ public void UpdateListViewModelList() Path.Join(_appDataPath, "npm-cache"), Path.Join(_localAppDataPath, "npm-cache"), }, - ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "npm"), + ExampleSubDirectory = Path.Join(PackagesStr, "npm"), }, new DevDriveCacheData { @@ -293,28 +291,28 @@ public void UpdateListViewModelList() Path.Join(_appDataPath, "vcpkg", ArchivesStr), Path.Join(_localAppDataPath, "vcpkg", ArchivesStr), }, - ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "vcpkg"), + ExampleSubDirectory = Path.Join(PackagesStr, "vcpkg"), }, new DevDriveCacheData { CacheName = "Cargo cache (Rust)", EnvironmentVariable = "CARGO_HOME", CacheDirectory = new List { Path.Join(_userProfilePath, ".cargo") }, - ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "cargo"), + ExampleSubDirectory = Path.Join(PackagesStr, "cargo"), }, new DevDriveCacheData { CacheName = "Maven cache (Java)", EnvironmentVariable = "MAVEN_OPTS", CacheDirectory = new List { Path.Join(_userProfilePath, ".m2") }, - ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "m2"), + ExampleSubDirectory = Path.Join(PackagesStr, "m2"), }, new DevDriveCacheData { CacheName = "Gradle cache (Java)", EnvironmentVariable = "GRADLE_USER_HOME", CacheDirectory = new List { Path.Join(_userProfilePath, ".gradle") }, - ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "gradle"), + ExampleSubDirectory = Path.Join(PackagesStr, "gradle"), } ]; @@ -380,11 +378,12 @@ public void UpdateOptimizerListViewModelList() existingDevDriveLetters.Add(existingDevDrive.DriveLetter.ToString()); } + var exampleDirectory = Path.Join(existingDevDriveLetters[0] + ":", cache.ExampleSubDirectory); var card = new DevDriveOptimizerCardViewModel( _optimizeDevDriveDialogViewModelFactory, cache.CacheName!, existingCacheLocation, - cache.ExampleDirectory!, // example location on dev drive to move cache to + exampleDirectory!, // example location on dev drive to move cache to cache.EnvironmentVariable!, // environmentVariableToBeSet existingDevDriveLetters); DevDriveOptimizerCardCollection.Add(card);