2023-09-14 09:05:16 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 by Claudio Cambra <claudio.cambra@nextcloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2023-09-14 10:37:04 +03:00
|
|
|
#import "fileproviderstorageuseenumerationobserver.h"
|
2023-09-14 09:05:16 +03:00
|
|
|
|
2023-09-14 10:37:04 +03:00
|
|
|
@implementation FileProviderStorageUseEnumerationObserver
|
|
|
|
|
|
|
|
- (instancetype)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self) {
|
2023-09-28 14:59:45 +03:00
|
|
|
_materialisedItems = [NSSet set];
|
2023-09-14 10:37:04 +03:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NSFileProviderEnumerationObserver protocol methods
|
|
|
|
- (void)didEnumerateItems:(NSArray<id<NSFileProviderItem>> *)updatedItems
|
|
|
|
{
|
2023-09-28 14:48:54 +03:00
|
|
|
NSMutableSet<id<NSFileProviderItem>> * const existingItems = self.materialisedItems.mutableCopy;
|
|
|
|
|
2023-09-14 10:37:04 +03:00
|
|
|
for (const id<NSFileProviderItem> item in updatedItems) {
|
2023-09-28 12:48:47 +03:00
|
|
|
NSLog(@"StorageUseEnumerationObserver: Enumerating %@ with size %llu",
|
|
|
|
item.filename, item.documentSize.unsignedLongLongValue);
|
2023-09-28 14:48:54 +03:00
|
|
|
[existingItems addObject:item];
|
2023-09-14 10:37:04 +03:00
|
|
|
}
|
2023-09-28 14:48:54 +03:00
|
|
|
|
|
|
|
_materialisedItems = existingItems.copy;
|
2023-09-14 10:37:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)finishEnumeratingWithError:(NSError *)error
|
|
|
|
{
|
2023-09-25 17:10:28 +03:00
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2023-09-28 12:48:47 +03:00
|
|
|
self.enumerationFinishedHandler(error);
|
2023-09-25 17:10:28 +03:00
|
|
|
});
|
2023-09-14 10:37:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)finishEnumeratingUpToPage:(NSFileProviderPage)nextPage
|
|
|
|
{
|
2023-09-25 17:10:28 +03:00
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2023-09-28 12:48:47 +03:00
|
|
|
self.enumerationFinishedHandler(nil);
|
2023-09-25 17:10:28 +03:00
|
|
|
});
|
2023-09-14 10:37:04 +03:00
|
|
|
}
|
2023-09-14 09:05:16 +03:00
|
|
|
|
|
|
|
@end
|