LibraryFileAlias URL comes from wrong store

Bug #632880 reported by Jeroen T. Vermeulen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Low
Jeroen T. Vermeulen

Bug Description

When rendering e.g. an icon, we use LibraryFileAlias.getURL. This in turn uses LibraryFileAlias.http_url, which calls LibrarianClient.getURLForAlias.

There is a subtle problem between the latter two. You'd expect http_url to ask getURLForAlias for "the URL for this LibraryFileAlias." But instead, it asks for "the URL for the LibraryFileAlias with this ID." So there's a redundant lookup for "the LibraryFileAlias with the same ID as this LibraryFileAlias." You don't normally notice this of course, because the right object is already cached.

But there is a case where you do notice. If the LibraryFileAlias was retrieved from the slave store but the current request uses the master store by default. Then you do get an extra database query, and on our precious master store—and it also bypasses any prejoining you might have done to get the slave-side LibraryFileAliases in the first place.

The solution: make FileDownloadClient._getPathForAlias accept a LibraryFileAlias as an alternative to a LibraryFileAlias.id (and so skip the lookup). Document FileDownloadCLient.getURLForAlias as accepting either as well. Then make LibraryFileAlias.http_url return self.client.getURLForAlias(self) instead of self.client.getURLForAlias(self.id).

Related branches

Changed in launchpad-foundations:
status: New → In Progress
importance: Undecided → Low
assignee: nobody → Jeroen T. Vermeulen (jtv)
milestone: none → 10.10
Changed in launchpad-foundations:
status: In Progress → Fix Committed
tags: added: qa-ok timeout
Revision history for this message
Launchpad QA Bot (lpqabot) wrote : Bug fixed by a commit
tags: added: qa-needstesting
removed: qa-ok
tags: added: qa-ok
removed: qa-needstesting
tags: removed: timeout
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.