When patching, close base file before renaming

Bug #1449151 reported by David Coppit
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Duplicity
Fix Released
Medium
Unassigned

Bug Description

This code in path.py doesn't close "self" before attempting to rename temp_path to self:

    def patch_with_attribs(self, diff_ropath):
        """Patch self with diff and then copy attributes over"""
        assert self.isreg() and diff_ropath.isreg()
        temp_path = self.get_temp_in_same_dir()
        patch_fileobj = librsync.PatchedFile(self.open("rb"),
                                             diff_ropath.open("rb"))
        temp_path.writefileobj(patch_fileobj)
        diff_ropath.copy_attribs(temp_path)
        temp_path.rename(self)

On a NetApp mounted over a CIFS connection, this fails. The following closes the file handles, and works fine:

    def patch_with_attribs(self, diff_ropath):
        """Patch self with diff and then copy attributes over"""
        assert self.isreg() and diff_ropath.isreg()
        temp_path = self.get_temp_in_same_dir()
        fbase = self.open("rb")
        fdiff = diff_ropath.open("rb")
        patch_fileobj = librsync.PatchedFile(fbase, fdiff)
        temp_path.writefileobj(patch_fileobj)
        assert not fbase.close()
        assert not fdiff.close()
        diff_ropath.copy_attribs(temp_path)
        temp_path.rename(self)

Note that this opened file handle is the root cause for bug 1448249. So fixing this one fixes that one too, at least on my system.

Changed in duplicity:
importance: Undecided → Medium
milestone: none → 0.7.03
status: New → Fix Committed
Changed in duplicity:
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.