Skip to content

Commit

Permalink
Fix: Fixed an issue with Nutstore cloud drive detection (#15445)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfu91 authored May 23, 2024
1 parent 8611491 commit bab19d7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Files.App/Utils/Cloud/CloudDrivesDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,23 @@ private static Task<IEnumerable<ICloudProvider>> DetectNutstoreDrive()
string iconPath = Path.Combine(programFilesFolder, "Nutstore", "Nutstore.exe");
var iconFile = Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List<int>() { 101 }).FirstOrDefault();

// get every folder under the Nutstore folder in %userprofile%
var mainFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Nutstore");
var nutstoreFolders = Directory.GetDirectories(mainFolder, "Nutstore", SearchOption.AllDirectories);
foreach (var nutstoreFolder in nutstoreFolders)
using var syncRootMangerKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager");
if (syncRootMangerKey is not null)
{
var folderName = Path.GetFileName(nutstoreFolder);
if (folderName is not null && folderName.StartsWith("Nutstore", StringComparison.OrdinalIgnoreCase))
var syncRootIds = syncRootMangerKey.GetSubKeyNames();
foreach (var syncRootId in syncRootIds)
{
if (!syncRootId.StartsWith("Nutstore-")) continue;

var sid = syncRootId.Split('!')[1];
using var syncRootKey = syncRootMangerKey.OpenSubKey($@"{syncRootId}\UserSyncRoots");
var userSyncRoot = syncRootKey?.GetValue(sid)?.ToString();
if (string.IsNullOrEmpty(userSyncRoot)) continue;

results.Add(new CloudProvider(CloudProviders.Nutstore)
{
Name = $"Nutstore",
SyncFolder = nutstoreFolder,
SyncFolder = userSyncRoot,
IconData = iconFile?.IconData
});
}
Expand Down

0 comments on commit bab19d7

Please sign in to comment.