On Tuesday, December 05, 2006, at 11:25AM, "Scott Ribe" <email@hidden> wrote:
>I've got a program that stores many fairly small text items in a single
>database file. For purposes of this question, it's much like Entourage's
>email database, although it's not actually email. I want my items searchable
>by spotlight, and I think I understand the basics:
>
>- export each item as an individual file, with a distinct type
And that type is described by a UTI exported by your importer, or declared in the application's Info.plist.
>- Where best to store the items?
~/Library/Caches/Metadata/com.me.myapplication
>How to specify the type so that, like
>Entourage emails, matches in Spotlight do not reveal their location on disk
>in a Get Info?
I wish I knew a way to keep from revealing the cache file location, but AFAIK the only thing you can do is use kMDItemDisplayName to ensure that users get a decent display in the Spotlight search results.
>I don't really have useful metadata to offer, so is it
>possible to specify a UTI such that the type is text and Spotlight will
>index it without a custom importer, but a subtype causes my app to get the
>open request?
Not as far as I know; you'd have to declare your metadata item UTI as public.text (I think) to use the system's plain text importer, but then it will just be opened by whatever program opens plain text.
>- How to keep the export directory and database in synch, in the case that a
>user copies/moves/restores the database file? I am not able to do much at
>all with the data format at this time. (Cross-platform format, would have to
>wait for a future revision cycle.) I can squeeze some bytes into reserved
>space in the header, so I'm thinking a UUID to identify the database file
>and an update count to track its version, with those stored with the text
>item so that I can tell if the database does not match the text files
>indexed by Spotlight, and re-export. Am I missing anything here? This does
>mean that a database copied onto the computer would not result in the
>Spotlight index being updated until my app is run, but I can live with that.
The way we're doing this in BibDesk (similar situation; many text records in a text file) is to re-save all items to the cache when first saving a file, even if it's been saved previously. After that, we mark edited items as dirty and re-export only the changed ones to the metadata cache when the user saves the file (if the user deletes an item it's removed from the cache immediately). My original implementation just re-exported all the items every time the user saved, and that worked okay as well. Since it happened in a background thread, the performance hit was mainly noticeable through mds re-indexing all the items.
Not sure if that's helpful to you or not. Keeping items synched is the part that makes this metadata caching business ugly, IMO.
hth,
Adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Spotlight-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden