Skip to content

Commit

Permalink
Addressed PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SohamDas2021 committed Apr 9, 2024
1 parent 14100ee commit caeaad9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public partial class DevDriveCacheData

public List<string>? CacheDirectory { get; set; }

public string? ExampleDirectory { get; set; }
public string? ExampleSubDirectory { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</data>
<data name="ExampleText" xml:space="preserve">
<value>Example: </value>
<comment>Example string</comment>
<comment>Example string, will be followed by a sample location to move the cache to a dev drive location</comment>
</data>
<data name="EndTaskOnTaskBar.Header" xml:space="preserve">
<value>End Task</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private int MoveDirectory(string sourceDirectory, string targetDirectory)
catch (Exception ex)
{
Log.Error($"Error in MoveDirectory. Error: {ex}");
TelemetryFactory.Get<ITelemetry>().LogError("DevDriveInsights_PackageCacheMove_Error", LogLevel.Critical, new ExceptionEvent(ex.HResult, sourceDirectory));
TelemetryFactory.Get<ITelemetry>().LogError("DevDriveInsights_PackageCacheMoveDirectory_Error", LogLevel.Critical, new ExceptionEvent(ex.HResult, sourceDirectory));
return ex.HResult;
}
}
Expand Down Expand Up @@ -173,7 +173,7 @@ private void DirectoryInputConfirmed()
{
SetEnvironmentVariable(EnvironmentVariableToBeSet, directoryPath);
Log.Debug($"Moved cache from {ExistingCacheLocation} to {directoryPath}");
TelemetryFactory.Get<ITelemetry>().Log("DevDriveInsights_PackageCacheMoved_Event", LogLevel.Critical, new ExceptionEvent(0, ExistingCacheLocation));
TelemetryFactory.Get<ITelemetry>().Log("DevDriveInsights_PackageCacheMovedSuccessfully_Event", LogLevel.Critical, new ExceptionEvent(0, ExistingCacheLocation));
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<string> { Path.Join(_userProfilePath, ".nuget", PackagesStr) },
ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "NuGet", CacheStr),
ExampleSubDirectory = Path.Join(PackagesStr, "NuGet", CacheStr),
},
new DevDriveCacheData
{
Expand All @@ -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
{
Expand All @@ -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<string> { 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<string> { 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<string> { Path.Join(_userProfilePath, ".gradle") },
ExampleDirectory = Path.Join(ExampleDevDriveDirStr, PackagesStr, "gradle"),
ExampleSubDirectory = Path.Join(PackagesStr, "gradle"),
}
];

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit caeaad9

Please sign in to comment.