component/package.js — pull request #1 by dominicbarnes (2013-12-15 04:10:49+00:00)
Title: Addressing race-conditions caused by the destroy calls

When working with multiple remotes, the use of `Package#destroy()` here has been causing corrupted installations due to a nasty race condition.

The race happens for a component that is depended on multiple times. When a remote is missed (happened a lot for my team since we used a custom remote for only a select few libs) the destroy runs, but then another install gets started in the interim. As our component list grew, this happened more and more frequently, until you had to get "lucky" and it just worked.

The solution is to only trigger the destroy when a component could not be found on any remotes. (rather than on each error)