Skip to content

Commit

Permalink
Keep track of materialised files in storageuseenumerationobserver
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Sep 28, 2023
1 parent 5e723f3 commit 777bb9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/macOS/fileproviderstorageuseenumerationobserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ typedef void(^UsageEnumerationFinishedHandler)(NSError *const error);

@property (readwrite, strong) UsageEnumerationFinishedHandler enumerationFinishedHandler;
@property (readonly) NSUInteger usage;
@property (readonly) NSSet<id<NSFileProviderItem>> *materialisedItems;

@end
5 changes: 5 additions & 0 deletions src/gui/macOS/fileproviderstorageuseenumerationobserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ - (instancetype)init
// NSFileProviderEnumerationObserver protocol methods
- (void)didEnumerateItems:(NSArray<id<NSFileProviderItem>> *)updatedItems
{
NSMutableSet<id<NSFileProviderItem>> * const existingItems = self.materialisedItems.mutableCopy;

for (const id<NSFileProviderItem> item in updatedItems) {
NSLog(@"StorageUseEnumerationObserver: Enumerating %@ with size %llu",
item.filename, item.documentSize.unsignedLongLongValue);

_usage += item.documentSize.unsignedLongLongValue;
[existingItems addObject:item];
}

_materialisedItems = existingItems.copy;
}

- (void)finishEnumeratingWithError:(NSError *)error
Expand Down

0 comments on commit 777bb9f

Please sign in to comment.