~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-30 22:01:00 UTC
  • mto: (1711.4.39 win32-accepted)
  • mto: This revision was merged to the branch mainline in revision 1836.
  • Revision ID: john@arbash-meinel.com-20060630220100-5e348dced9dfd531
try/finally to close files, _KnitData was keeping a handle to a file it never used again, and using transport.rename() when it wanted transport.move()

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
    def append(self, relpath, f, mode=None):
173
173
        """Append the text in the file-like object into the final location."""
174
174
        abspath = self._abspath(relpath)
 
175
        fp = None
175
176
        try:
176
 
            fp = open(abspath, 'ab')
177
 
            # FIXME should we really be chmodding every time ? RBC 20060523
178
 
            if mode is not None:
179
 
                os.chmod(abspath, mode)
180
 
        except (IOError, OSError),e:
181
 
            self._translate_error(e, relpath)
182
 
        # win32 workaround (tell on an unwritten file returns 0)
183
 
        fp.seek(0, 2)
184
 
        result = fp.tell()
185
 
        self._pump(f, fp)
 
177
            try:
 
178
                fp = open(abspath, 'ab')
 
179
                # FIXME should we really be chmodding every time ? RBC 20060523
 
180
                if mode is not None:
 
181
                    os.chmod(abspath, mode)
 
182
            except (IOError, OSError),e:
 
183
                self._translate_error(e, relpath)
 
184
            # win32 workaround (tell on an unwritten file returns 0)
 
185
            fp.seek(0, 2)
 
186
            result = fp.tell()
 
187
            self._pump(f, fp)
 
188
        finally:
 
189
            if fp is not None:
 
190
                fp.close()
186
191
        return result
187
192
 
188
193
    def copy(self, rel_from, rel_to):