Skip to content

Commit ff93aa7

Browse files
Josh65-2201yaira2
andauthoredApr 14, 2024··
Feature: Added Lucid Link to the list of cloud drives (#15176)
Co-authored-by: Yair <39923744+yaira2@users.noreply.github.com>
1 parent a05a5e5 commit ff93aa7

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed
 

‎src/Files.App/Utils/Cloud/CloudProviders.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public enum CloudProviders
4343

4444
ownCloud,
4545

46-
ProtonDrive
46+
ProtonDrive,
47+
48+
LucidLink
4749
}
4850
}

‎src/Files.App/Utils/Cloud/Detector/CloudDetector.cs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ private static IEnumerable<ICloudDetector> EnumerateDetectors()
3333
yield return new BoxCloudDetector();
3434
yield return new GenericCloudDetector();
3535
yield return new SynologyDriveCloudDetector();
36+
yield return new LucidLinkCloudDetector();
3637
}
3738
}
3839
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) 2024 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
4+
using Files.App.Utils.Cloud;
5+
using System.IO;
6+
using System.Text.Json;
7+
using Windows.Storage;
8+
9+
namespace Files.App.Utils.Cloud
10+
{
11+
/// <summary>
12+
/// Provides an utility for LucidLink Cloud detection.
13+
/// </summary>
14+
public sealed class LucidLinkCloudDetector : AbstractCloudDetector
15+
{
16+
protected override async IAsyncEnumerable<ICloudProvider> GetProviders()
17+
{
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;
23+
24+
if (jsonElem.TryGetProperty("filespaces", out JsonElement filespaces))
25+
{
26+
foreach (JsonElement inner in filespaces.EnumerateArray())
27+
{
28+
string syncFolder = inner.GetProperty("filespaceName").GetString();
29+
30+
string[] orgNameFilespaceName = syncFolder.Split(".");
31+
string path = Path.Combine(@"C:\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]);
32+
string filespaceName = orgNameFilespaceName[0];
33+
34+
string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Lucid", "resources", "Logo.ico");
35+
StorageFile iconFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());
36+
37+
yield return new CloudProvider(CloudProviders.LucidLink)
38+
{
39+
Name = $"Lucid Link ({filespaceName})",
40+
SyncFolder = path,
41+
IconData = iconFile is not null ? await iconFile.ToByteArrayAsync() : null,
42+
};
43+
}
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)
Please sign in to comment.