I am working on an NSFileProviderEnumerator in my iOS application to enumerate the contents of a directory. However, I'm experiencing an issue where duplicate items are being created during the reimport process.
Here is my enumeration code snippet:
items.append(FileProviderItem(
identifier: NSFileProviderItemIdentifier(rawValue: item.mid),
name: item.name,
kind: item.kind.rawValue,
parent: parent,
size: size,
modificationDateInMilliseconds: modificationDateInMilliseconds ?? nil))
The problem arises when I have a folder at the root level, let's say "Root". When I trigger reimport, it creates a duplicate folder named "Root2". And when I restart the app, "Root2" appears inside the "Root" folder. This is not the intended behavior - I would like the reimport to enumerate the existing items without creating duplicates.
I'm not sure what I'm doing wrong here. I would appreciate any insights on how to correctly enumerate contents during reimport without creating duplicate items. Thanks in advance.