Reinstall extension media when the version of the extension changes.

Review Request #5673 — Created April 3, 2014 and submitted — Latest diff uploaded

Information

Djblets
master
c1e7873...

Reviewers

Upgrades for extensions which include static media (like javascript or CSS) are
highly annoying, because in addition to installing the package, the user has to
disable the extension, then re-enable it. This change fixes all that.

When we install extension static media, we add a key to the extension settings
dictionary called _extension_media_version. Then, when initializing the
extension class, if the version stored in settings doesn't match the one for
the running code, we'll re-install the media.

This is fine and dandy for the single-threaded devserver, but it's possible
that installing a new extension could cause a bunch of threads/processes to try
to reinstall static media all at once on a production server. I've therefore
created a relatively simple locking mechanism to ensure that only one thread
will be installing media for any given extension at a time.

Testing done:

  • Enabled a new extension and saw the media get installed.
  • Disabled an existing extension and re-enabled it, and saw media get installed.
  • Restarted my devserver and saw that static media versions were checked, but no re-installation occurred.
  • Updated the version of an extension, restarted the devserver, and saw that static media got upgraded.
  • Created a lock contention and saw that initializing the extension waited for the lock to clear.
    Loading...