Skip to content

Commit bab19d7

Browse files
authored
Fix: Fixed an issue with Nutstore cloud drive detection (#15445)
1 parent 8611491 commit bab19d7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Files.App/Utils/Cloud/CloudDrivesDetector.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,18 +270,23 @@ private static Task<IEnumerable<ICloudProvider>> DetectNutstoreDrive()
270270
string iconPath = Path.Combine(programFilesFolder, "Nutstore", "Nutstore.exe");
271271
var iconFile = Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List<int>() { 101 }).FirstOrDefault();
272272

273-
// get every folder under the Nutstore folder in %userprofile%
274-
var mainFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Nutstore");
275-
var nutstoreFolders = Directory.GetDirectories(mainFolder, "Nutstore", SearchOption.AllDirectories);
276-
foreach (var nutstoreFolder in nutstoreFolders)
273+
using var syncRootMangerKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager");
274+
if (syncRootMangerKey is not null)
277275
{
278-
var folderName = Path.GetFileName(nutstoreFolder);
279-
if (folderName is not null && folderName.StartsWith("Nutstore", StringComparison.OrdinalIgnoreCase))
276+
var syncRootIds = syncRootMangerKey.GetSubKeyNames();
277+
foreach (var syncRootId in syncRootIds)
280278
{
279+
if (!syncRootId.StartsWith("Nutstore-")) continue;
280+
281+
var sid = syncRootId.Split('!')[1];
282+
using var syncRootKey = syncRootMangerKey.OpenSubKey($@"{syncRootId}\UserSyncRoots");
283+
var userSyncRoot = syncRootKey?.GetValue(sid)?.ToString();
284+
if (string.IsNullOrEmpty(userSyncRoot)) continue;
285+
281286
results.Add(new CloudProvider(CloudProviders.Nutstore)
282287
{
283288
Name = $"Nutstore",
284-
SyncFolder = nutstoreFolder,
289+
SyncFolder = userSyncRoot,
285290
IconData = iconFile?.IconData
286291
});
287292
}

0 commit comments

Comments
 (0)