iCloud - NSMetadataQuery returning old results, showing deleted files

339 Views Asked by At

As the title says, my NSMetadataQueries to iCloud sometimes show files that I just deleted from iCloud.

I can even download them after being deleted. Does anybody know what causes the queries to return wrong results / what can I do to prevent this?

1

There are 1 best solutions below

0
On

I just noticed the same issue. I logged the document urls and saw that the documents where in a folder named .Trash.

Here's how to reproduce this:

  1. I delete a document in iCloud Drive on my Mac in Finder
    • → The document disappears from my Mac
  2. The document still shows on iOS, but the path for the NSMetadataItem now contains .Trash
  3. If I empty the Trash on my Mac, the file disappears from my iOS app

So the solution is to check if the file is in the trash and hide it.