Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/Files.App/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2494,12 +2494,7 @@ await Task.Run(async () =>
// after the final list update, which would delay load completion and watcher setup.
// The desktop.ini task is awaited before applying the adaptive layout, which reads DesktopIni.
_ = dispatcherQueue.EnqueueOrInvokeAsync(CheckForSolutionFile, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
desktopIniUpdateTask = dispatcherQueue.EnqueueOrInvokeAsync(() =>
{
GetDesktopIniFileData();
CheckForBackgroundImage();
},
Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
desktopIniUpdateTask = UpdateDesktopIniAsync(path, cancellationToken);
});

// Cache the resolved folder so the post-enum switch reuses it.
Expand Down Expand Up @@ -2584,12 +2579,18 @@ private void CheckForSolutionFile()
.FirstOrDefault()?.ItemPath;
}

private void GetDesktopIniFileData()
private async Task UpdateDesktopIniAsync(string directoryPath, CancellationToken cancellationToken)
{
var workingDirectory = WorkingDirectory
?? throw new InvalidOperationException("The working directory has not been initialized.");
var path = Path.Combine(workingDirectory, "desktop.ini");
DesktopIni = WindowsIniService.GetData(path);
// File.Exists and ReadLines can wait for the SMB timeout on an unavailable share.
var data = await Task.Run(() => WindowsIniService.GetData(Path.Combine(directoryPath, "desktop.ini")));
await dispatcherQueue.EnqueueOrInvokeAsync(() =>
{
if (cancellationToken.IsCancellationRequested || WorkingDirectory != directoryPath)
return;

DesktopIni = data;
CheckForBackgroundImage();
}, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
}

public void CheckForBackgroundImage()
Expand Down