Skip to content

Commit 538beea

Browse files
committed
Add feature to detect symlinks recursively
1 parent c93a484 commit 538beea

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,38 @@ private async IAsyncEnumerable<ICloudProvider> GetLucidLinkV3Providers(string vo
2828
{
2929
foreach (string directory in Directory.GetDirectories(volumePath))
3030
{
31-
if (IsSymlink(directory))
31+
await foreach (var provider in GetProvidersFromDirectory(directory))
3232
{
33-
string[] orgNameFilespaceName = directory.Split("\\");
34-
string path = Path.Combine($@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Volumes", orgNameFilespaceName[orgNameFilespaceName.Length - 1], orgNameFilespaceName[orgNameFilespaceName.Length - 2]);
35-
string filespaceName = orgNameFilespaceName[orgNameFilespaceName.Length - 2];
36-
37-
StorageFile iconFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());
38-
39-
yield return new CloudProvider(CloudProviders.LucidLink)
40-
{
41-
Name = $"Lucid Link ({filespaceName})",
42-
SyncFolder = path,
43-
IconData = iconFile is not null ? await iconFile.ToByteArrayAsync() : null,
44-
};
33+
yield return provider;
34+
}
35+
}
36+
}
37+
}
38+
39+
private async IAsyncEnumerable<ICloudProvider> GetProvidersFromDirectory(string directory)
40+
{
41+
foreach (string subDirectory in Directory.GetDirectories(directory))
42+
{
43+
if (IsSymlink(subDirectory))
44+
{
45+
string[] orgNameFilespaceName = subDirectory.Split("\\");
46+
string path = Path.Combine($@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Volumes", orgNameFilespaceName[orgNameFilespaceName.Length - 1], orgNameFilespaceName[orgNameFilespaceName.Length - 2]);
47+
string filespaceName = orgNameFilespaceName[orgNameFilespaceName.Length - 2];
48+
49+
StorageFile iconFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());
50+
51+
yield return new CloudProvider(CloudProviders.LucidLink)
52+
{
53+
Name = $"Lucid Link ({filespaceName})",
54+
SyncFolder = path,
55+
IconData = iconFile is not null ? await iconFile.ToByteArrayAsync() : null,
56+
};
57+
}
58+
else
59+
{
60+
await foreach (var provider in GetProvidersFromDirectory(subDirectory))
61+
{
62+
yield return provider;
4563
}
4664
}
4765
}

0 commit comments

Comments
 (0)