Revok gets this information from two macOS Spotlight keys:
kMDItemLastUsedDate
and
kMDItemUseCount
. These attributes can be somewhat brittle. Here's why:
kMDItemLastUsedDate
- Not Updated Reliably by All Apps: Only applications that use Apple's standard file access APIs (like NSDocument or similar frameworks) reliably update it. Fortunately, most Mac apps use these APIs.
- Caching and Spotlight Index Delays: Spotlight relies on background indexing, which means there's often a lag between actual usage and metadata updates. Cached values may remain stale if the indexer hasn’t refreshed.
- Not Updated on All Access Events: For example, viewing a file in Quick Look or accessing via Terminal might not count as a "use" for Spotlight. Even just opening a file isn't guaranteed to update
kMDItemLastUsedDate
unless the app "touches" the file in a specific, trackable way.
- macOS Security: Certain metadata access is limited unless the app has Full Disk access permission.
- Dependent on Spotlight being Enabled: If Spotlight indexing is disabled for a volume or if the index is corrupted,
kMDItemLastUsedDate
won’t update or might be missing entirely.
kMDItemUseCount
- Not Updated Reliably by All Apps: It’s typically only updated by AppKit-based apps (e.g., Preview, TextEdit).
Not Present on All File Types: Certain files simply don’t get this metadata applied, especially system files, unsigned apps, or files in excluded volumes.
- No TTL for Data: There's no mechanism to track resets, so it's quite common for application updates and re-installs to reset the data. Sometimes this data is preserved across updates and sometimes it's not.