please add 'filename' key to bug_attachment

Bug #254595 reported by Markus Korn
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
High
Unassigned
launchpadlib
Invalid
High
Unassigned

Bug Description

I'm not sure if launchpadlib is the right target for this bugreport, but it would be nice if a bug_attachment entry could have a 'filename' attribute.

Markus

Revision history for this message
Markus Korn (thekorn) wrote :

There is a very unfortunate side effect of this bug: when I change the content of an attachment like

>>> attachment = bug.attachments[1].data
>>> f = attachment.open("w", content_type)
>>> f.write("boo bar baz")
>>> f.close()

this file is renamed.

Example (first attachment on https://bugs.staging.launchpad.net/buglog-data/+bug/249127):
 - uploading via web-UI, the link is like: http://staging.launchpadlibrarian.net/17613488/test_attachment.txt
 - changing the content via launchpadlib, it points to http://staging.launchpadlibrarian.net/17613488/data

Markus

Changed in launchpadlib:
importance: Undecided → High
status: New → Triaged
Revision history for this message
Markus Korn (thekorn) wrote :

I don't know anything about the internals, but this bug seems to related to bug 270703

Revision history for this message
Brad Crittenden (bac) wrote :

Yes, bug 270703 is related to the first issue in this bug. Moving this bug to launchpad-foundations.

Changed in launchpad-foundations:
importance: Undecided → High
status: New → Triaged
Changed in launchpadlib:
status: Triaged → Invalid
Revision history for this message
Leonard Richardson (leonardr) wrote :

The basic problem underlying both these bugs is that we have no representation for the file's metadata. Sending GET to the file just redirects you to the library. If there was a JSON representation of the file we could serve filename, timestamp, etc for clients who requested JSON. For clients who expressed no preference as to file type we could serve the redirect.

But there's another problem specific to this bug, which is that when Launchpad overwrites a file it changes its name to 'data' instead of using the existing filename. I'm looking into that now.

Revision history for this message
Leonard Richardson (leonardr) wrote :

I've written and gotten reviewed a Launchpad branch and a launchpadlib branch that stop the stealth file renames by forcing you to specify the filename when you upload a file. That fixes this bug and part of 270703.

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.