diff --git a/Penumbra/Interop/CloudApi.cs b/Penumbra/Interop/CloudApi.cs
index 9ec29fa5..603d4c9f 100644
--- a/Penumbra/Interop/CloudApi.cs
+++ b/Penumbra/Interop/CloudApi.cs
@@ -4,21 +4,39 @@ public static unsafe partial class CloudApi
{
private const int CfSyncRootInfoBasic = 0;
+ /// Determines whether a file or directory is cloud-synced using OneDrive or other providers that use the Cloud API.
+ /// Can be expensive. Callers should cache the result when relevant.
public static bool IsCloudSynced(string path)
{
- var buffer = stackalloc long[1];
- var hr = CfGetSyncRootInfoByPath(path, CfSyncRootInfoBasic, buffer, sizeof(long), out var length);
- Penumbra.Log.Information($"{nameof(CfGetSyncRootInfoByPath)} returned HRESULT {hr}");
+ var buffer = stackalloc long[1];
+ int hr;
+ uint length;
+ try
+ {
+ hr = CfGetSyncRootInfoByPath(path, CfSyncRootInfoBasic, buffer, sizeof(long), out length);
+ }
+ catch (DllNotFoundException)
+ {
+ Penumbra.Log.Debug($"{nameof(CfGetSyncRootInfoByPath)} threw DllNotFoundException");
+ return false;
+ }
+ catch (EntryPointNotFoundException)
+ {
+ Penumbra.Log.Debug($"{nameof(CfGetSyncRootInfoByPath)} threw EntryPointNotFoundException");
+ return false;
+ }
+
+ Penumbra.Log.Debug($"{nameof(CfGetSyncRootInfoByPath)} returned HRESULT 0x{hr:X8}");
if (hr < 0)
return false;
if (length != sizeof(long))
{
- Penumbra.Log.Warning($"Expected {nameof(CfGetSyncRootInfoByPath)} to return {sizeof(long)} bytes, got {length} bytes");
+ Penumbra.Log.Debug($"Expected {nameof(CfGetSyncRootInfoByPath)} to return {sizeof(long)} bytes, got {length} bytes");
return false;
}
- Penumbra.Log.Information($"{nameof(CfGetSyncRootInfoByPath)} returned {{ SyncRootFileId = 0x{*buffer:X16} }}");
+ Penumbra.Log.Debug($"{nameof(CfGetSyncRootInfoByPath)} returned {{ SyncRootFileId = 0x{*buffer:X16} }}");
return true;
}