Skip to content

Commit 459d805

Browse files
authored
Feature: Added support for Lucid Link v3 (#16594)
1 parent aaefa0a commit 459d805

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.Utils.Cloud;
54
using System.IO;
6-
using System.Text.Json;
75
using Windows.Storage;
86

97
namespace Files.App.Utils.Cloud
@@ -13,25 +11,34 @@ namespace Files.App.Utils.Cloud
1311
/// </summary>
1412
public sealed class LucidLinkCloudDetector : AbstractCloudDetector
1513
{
14+
private readonly string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Lucid", "resources", "Logo.ico");
15+
1616
protected override async IAsyncEnumerable<ICloudProvider> GetProviders()
1717
{
18-
string jsonPath = Path.Combine(Environment.GetEnvironmentVariable("UserProfile"), ".lucid", "app.json");
19-
20-
var configFile = await StorageFile.GetFileFromPathAsync(jsonPath);
21-
using var jsonFile = JsonDocument.Parse(await FileIO.ReadTextAsync(configFile));
22-
var jsonElem = jsonFile.RootElement;
18+
string volumePath = Path.Combine(Constants.UserEnvironmentPaths.SystemDrivePath, "Volumes");
2319

24-
if (jsonElem.TryGetProperty("filespaces", out JsonElement filespaces))
20+
if (Directory.Exists(volumePath))
2521
{
26-
foreach (JsonElement inner in filespaces.EnumerateArray())
22+
foreach (string directory in Directory.GetDirectories(volumePath))
2723
{
28-
string syncFolder = inner.GetProperty("filespaceName").GetString();
24+
await foreach (var provider in GetProvidersFromDirectory(directory))
25+
{
26+
yield return provider;
27+
}
28+
}
29+
}
30+
}
2931

30-
string[] orgNameFilespaceName = syncFolder.Split(".");
31-
string path = Path.Combine($@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]);
32-
string filespaceName = orgNameFilespaceName[0];
32+
private async IAsyncEnumerable<ICloudProvider> GetProvidersFromDirectory(string directory)
33+
{
34+
foreach (string subDirectory in Directory.GetDirectories(directory))
35+
{
36+
if (Win32Helper.HasFileAttribute(subDirectory, System.IO.FileAttributes.ReparsePoint))
37+
{
38+
string[] orgNameFilespaceName = subDirectory.Split("\\");
39+
string path = Path.Combine($@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Volumes", orgNameFilespaceName[^2], orgNameFilespaceName[^1]);
40+
string filespaceName = orgNameFilespaceName[^1];
3341

34-
string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Lucid", "resources", "Logo.ico");
3542
StorageFile iconFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());
3643

3744
yield return new CloudProvider(CloudProviders.LucidLink)
@@ -41,6 +48,13 @@ protected override async IAsyncEnumerable<ICloudProvider> GetProviders()
4148
IconData = iconFile is not null ? await iconFile.ToByteArrayAsync() : null,
4249
};
4350
}
51+
else
52+
{
53+
await foreach (var provider in GetProvidersFromDirectory(subDirectory))
54+
{
55+
yield return provider;
56+
}
57+
}
4458
}
4559
}
4660
}

0 commit comments

Comments
 (0)