quicksilver/Quicksilver — pull request #1363 by skurfer (2013-01-31 19:58:08+00:00)
Title: recreate objects that aren't in the catalog (demo)

Here's a proof-of-concept for what I was proposing in #1277. Rather than try to preserve objects in dictionary form, we just ask the class that created them in the first place to create them again.

## Notes ##

* I don't really like that there's a class method on `QSObject` and an instance method on `QSObjectSource` with nearly identical signatures. They aren't exactly the same thing, but then again, the name makes sense for both. Suggestions welcome.
* I don't know of a specific style rule on this, but you'll see that the type is optional for `+[QSObject recreateObjectOfType:withIdentifier:]`. I can't think of another method where the first argument is optional, while later ones are required. So maybe it should change, but to my English speaking ears, it sounded better the way it is.
* We pass the object source both identifier *and* type to make things easier on the object source. Some of them provide multiple types of objects and while you could probably sniff the identifier to figure out which you have, this is much cleaner.
* By not storing dictionaries, we don't have to worry about non-plist objects being present. This also means that if plug-ins change the metadata they store in objects, we don't care because they will always be freshly created, not pulled from an archive.
* Because this is implemented at the command level, it also allows you to use non-catalog objects in saved commands, droplets, etc. in addition to triggers.

I've implemented the "recreate" method in the filesystem object source and in the iTunes plug-in (see the ["resurrection" branch][1] on my fork) for demonstration purposes.

(FYI, through some mysterious magic, triggers would already work for files not in the catalog. That is, `objectWithIdentier:` would always find it. But the same method in the synonyms code would come up empty. It was driving me crazy, but I quit trying to figure it out since my goal was to fix the situation across the board.)

## Things to try ##

Or things I tried anyway. All of the following used to stop working after a restart.

* Create a synonym for a file that isn't in the catalog.
* Create a trigger that sets an EQ preset for iTunes, then disable the EQ presets catalog entry.
* Create a trigger that uses an Album, Artist, or Track. (I just used "Select in Command Window" to keep it quiet.)

[1]: https://github.com/skurfer/iTunes-qsplugin/tree/resurrection