Max
Max

Reputation: 2749

iCloud - NSMetadataQuery returning old results, showing deleted files

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?

Upvotes: 4

Views: 337

Answers (1)

Mark
Mark

Reputation: 6957

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.

Upvotes: 1

Related Questions