Skip to content

Commit

Permalink
Cleanup some Dev Drive Insights code (#3747)
Browse files Browse the repository at this point in the history
  • Loading branch information
krschau authored Sep 10, 2024
1 parent a1d7c69 commit 8226a7f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
3 changes: 3 additions & 0 deletions exclusion.dic
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
disksandvolumes
Quickstart
awaitable
fsutil
devdrv
runas
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void MakeDevDriveTrusted()
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = Path.Join(Environment.SystemDirectory, Fsutil);

// Run the fstutil cmd to trust the dev drive
// Run the fsutil cmd to trust the dev drive
startInfo.Arguments = $"devdrv trust /f {DriveLetter}:";
startInfo.UseShellExecute = true;
startInfo.Verb = "runas";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private async Task BrowseButtonClick(object sender)
};

folderPicker.FileTypeFilter.Add("*");
WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, Microsoft.UI.Xaml.Application.Current.GetService<Window>().GetWindowHandle());
WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, Application.Current.GetService<Window>().GetWindowHandle());
var folder = await folderPicker.PickSingleFolderAsync();

if (folder != null)
Expand Down Expand Up @@ -255,14 +255,15 @@ private void DirectoryInputConfirmed()
{
Task.Run(() =>
{
// Send message to the DevDriveInsightsViewModel to let it display the progress ring for the move
// WeakReferenceMessenger.Default.Send(new DevDriveOptimizingMessage(new DevDriveOptimizingData()));
if (MoveDirectory(ExistingCacheLocation, directoryPath))
{
SetEnvironmentVariable(EnvironmentVariableToBeSet, directoryPath);
var existingCacheLocationVetted = RemovePrivacyInfo(ExistingCacheLocation);
Log.Debug($"Moved cache from {existingCacheLocationVetted} to {directoryPath}");
TelemetryFactory.Get<ITelemetry>().Log("DevDriveInsights_PackageCacheMovedSuccessfully_Event", LogLevel.Critical, new ExceptionEvent(0, existingCacheLocationVetted));
TelemetryFactory.Get<ITelemetry>().Log(
"DevDriveInsights_PackageCacheMovedSuccessfully_Event",
LogLevel.Critical,
new ExceptionEvent(0, existingCacheLocationVetted));
// Send message to the DevDriveInsightsViewModel to let it refresh the Dev Drive insights UX
WeakReferenceMessenger.Default.Send(new DevDriveOptimizedMessage(new DevDriveOptimizedData()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
Expand All @@ -21,7 +20,6 @@
using Microsoft.Internal.Windows.DevHome.Helpers;
using Microsoft.Internal.Windows.DevHome.Helpers.FileExplorer;
using Microsoft.UI.Xaml;
using Microsoft.Windows.DevHome.SDK;
using Serilog;
using Windows.Storage;

Expand Down Expand Up @@ -165,21 +163,21 @@ public async Task AddFolderClick()
await Task.Run(async () =>
{
using var folderDialog = new WindowOpenFolderDialog();
StorageFolder? repoRootfolder = null;
StorageFolder? repoRootFolder = null;
try
{
repoRootfolder = await folderDialog.ShowAsync(Application.Current.GetService<Window>());
repoRootFolder = await folderDialog.ShowAsync(Application.Current.GetService<Window>());
}
catch (Exception ex)
{
_log.Error(ex, $"Error occured when selecting a folder for adding a repository.");
_log.Error(ex, $"Error occurred when selecting a folder for adding a repository.");
}
if (repoRootfolder != null && repoRootfolder.Path.Length > 0)
if (repoRootFolder != null && repoRootFolder.Path.Length > 0)
{
_log.Information($"Selected '{repoRootfolder.Path}' as location to register");
RepoTracker.AddRepositoryPath(_unassigned, repoRootfolder.Path);
_log.Information($"Selected '{repoRootFolder.Path}' as location to register");
RepoTracker.AddRepositoryPath(_unassigned, repoRootFolder.Path);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Serilog;
using Windows.Foundation;

namespace DevHome.Customization.ViewModels;

Expand Down

0 comments on commit 8226a7f

Please sign in to comment.