Librarian-backed HostedFile objects do not expose hash

Bug #1007195 reported by Colin Watson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Low
Michael Nelson

Bug Description

Here's some code from lib/lp/soyuz/scripts/queue.py, which I'm trying to replace with an API client:

                    # Check sha against existing file (bug #67014)
                    existing_sha = hashlib.sha1()
                    for chunk in filechunks(existing_file):
                        existing_sha.update(chunk)
                    existing_file.close()

                    # bail out if the sha1 differs
                    if libfile.content.sha1 != existing_sha.hexdigest():
                        raise CommandRunnerError("%s already present on disk "
                                                 "and differs from new file"
                                                 % libfile.filename)
                    else:
                        self.display("%s already on disk and checksum "
                                     "matches, skipping.")

As far as I can see, it's not possible to do a like-for-like replacement of this, because the HostedFile objects that you get on webservice clients if you export something as Bytes() don't expose LibraryFileContent.sha1 anywhere; so in order to check whether a file you already have on disk matches the one in the librarian, you have to download the librarian's copy and compare it directly. In the case at hand, a common source of filename collisions that would reach this code is *.orig.tar.* files, and those are often very large (tens or hundreds of megabytes).

It would be great if HostedFile objects (not HostedFileBuffer - constructing those requires downloading the value) exported the SHA-1 so that I could write a direct equivalent of the code above.

Related branches

Changed in launchpad:
status: New → Triaged
importance: Undecided → Low
tags: added: soyuz-build
Colin Watson (cjwatson)
summary: - Librarian-backed HostedFile objects do not expose SHA-1 hash
+ Librarian-backed HostedFile objects do not expose hash
Changed in launchpad:
status: Triaged → In Progress
assignee: nobody → Michael Nelson (michael.nelson)
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
Steve Kowalik (stevenk)
tags: added: qa-ok
removed: qa-needstesting
Steve Kowalik (stevenk)
Changed in launchpad:
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.