Implement eviction capabilities in FileProviderItem

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-02-20 15:58:19 +08:00
Родитель 3e5766be47
Коммит 60f116cdd4
1 изменённых файлов: 25 добавлений и 7 удалений

Просмотреть файл

@ -32,13 +32,25 @@ class FileProviderItem: NSObject, NSFileProviderItem {
var capabilities: NSFileProviderItemCapabilities {
guard !metadata.directory else {
return [
.allowsAddingSubItems,
.allowsContentEnumerating,
.allowsReading,
.allowsDeleting,
.allowsRenaming,
]
if #available(macOS 13.0, *) {
// .allowsEvicting deprecated on macOS 13.0+, use contentPolicy instead
return [
.allowsAddingSubItems,
.allowsContentEnumerating,
.allowsReading,
.allowsDeleting,
.allowsRenaming
]
} else {
return [
.allowsAddingSubItems,
.allowsContentEnumerating,
.allowsReading,
.allowsDeleting,
.allowsRenaming,
.allowsEvicting
]
}
}
guard !metadata.lock else {
return [.allowsReading]
@ -49,6 +61,7 @@ class FileProviderItem: NSObject, NSFileProviderItem {
.allowsDeleting,
.allowsRenaming,
.allowsReparenting,
.allowsEvicting
]
}
@ -133,6 +146,11 @@ class FileProviderItem: NSObject, NSFileProviderItem {
}
}
@available(macOSApplicationExtension 13.0, *)
var contentPolicy: NSFileProviderContentPolicy {
.downloadLazily
}
required init(
metadata: NextcloudItemMetadataTable,
parentItemIdentifier: NSFileProviderItemIdentifier,