~mbp/desktopcouch/461356-imports

« back to all changes in this revision

Viewing changes to desktopcouch/records/record.py

Removing an internal reference to an attachment isn't the same as expunging it from the database. Now, store the key of the attachment and expunge the attachment before attempting to add any attachments. (Fixes LP: #588421)

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
        validate(data)
126
126
        self._data = data
127
127
        self._attachments = dict()
 
128
        self._detached = set()
128
129
 
129
130
    def __getitem__(self, key):
130
131
        value = self._data[key]
169
170
        """Remove a BLOB attached to a document."""
170
171
        try:
171
172
            self._attachments.pop(filename)
 
173
            self._detached.add(filename)
172
174
        except KeyError:
173
175
            raise KeyError("%r is not attached to this document" % (filename,))
174
176