Spotlight metadata kMDItemLastUsedDate is not set when the attribute is set

Number:rdar://23202426 Date Originated:21-Oct-2015
Status:Open Resolved:No
Product:OS X Product Version:10.11
Classification:2 - Important Reproducible:Yes
kMDItemLastUsedDate is used to store when a document was last opened (I'm using this data for research purposes, but the problem arises also when searching using finder).

If an item is downloaded from the internet, OS X sets the flag ""
to the downloaded file. This flag prevents the kMDItemLastUsedDate from being set appropriately. This prevents files downloaded from the internet from being shown as spotlight search results based on last opened dates.

Steps to Reproduce:
1. Download a file from the internet (call this "somefile.pdf")
2. Open the given file using Preview
3. In terminal type mdls somefile.pdf
4. The kMDItemLastUsedDate metadata item does not show as one of the available metadata items, even if the file was opened recently
5. In terminal, type xattr -d somefile.pdf
6. Open the file using Preview
7. In terminal type mdls somefile.pdf
8. kMDItemLastUsedDate is now correctly shown

Expected Results:
kMDItemLastUsedDate should have appeared in step 4 above (immediately after opening file), but did not.

Actual Results:
kMDItemLastUsedDate only appears after the is removed from the file using xattr, but not before.



This seems to occur on every software and hardware configuration


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!