Skip to content

Commit 70970b7

Browse files
Fix: Prevent crash when sync root info is null (#17430)
Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
1 parent 39bec89 commit 70970b7

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/Files.App/Utils/Storage/Helpers/SyncRootHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private static unsafe (bool Success, ulong Capacity, ulong Used) GetSyncRootQuot
6060
return (false, 0, 0);
6161
}
6262

63-
if (syncRootInfo is null)
63+
if (syncRootInfo is null || syncRootInfo.Id is null)
6464
{
6565
return (false, 0, 0);
6666
}

src/Files.App/ViewModels/Properties/Items/DriveProperties.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,20 @@ public async override Task GetSpecialPropertiesAsync()
7171
return;
7272
}
7373

74-
var syncRootStatus = await SyncRootHelpers.GetSyncRootQuotaAsync(Drive.Path);
75-
if (syncRootStatus.Success)
74+
try
7675
{
77-
ViewModel.DriveCapacityValue = syncRootStatus.Capacity;
78-
ViewModel.DriveUsedSpaceValue = syncRootStatus.Used;
79-
ViewModel.DriveFreeSpaceValue = syncRootStatus.Capacity - syncRootStatus.Used;
80-
return;
76+
var syncRootStatus = await SyncRootHelpers.GetSyncRootQuotaAsync(Drive.Path);
77+
if (syncRootStatus.Success)
78+
{
79+
ViewModel.DriveCapacityValue = syncRootStatus.Capacity;
80+
ViewModel.DriveUsedSpaceValue = syncRootStatus.Used;
81+
ViewModel.DriveFreeSpaceValue = syncRootStatus.Capacity - syncRootStatus.Used;
82+
return;
83+
}
84+
}
85+
catch (Exception e)
86+
{
87+
App.Logger.LogWarning(e, "Failed to get sync root quota for path: {Path}", Drive.Path);
8188
}
8289

8390
try

0 commit comments

Comments
 (0)