]> arthur.barton.de Git - bup.git/commitdiff
save: handle backup write errors properly
authorBrandon Low <lostlogic@lostlogicx.com>
Wed, 12 Jan 2011 01:15:53 +0000 (17:15 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 18 Jan 2011 20:36:59 +0000 (12:36 -0800)
bup-save was catching all IOErrors and treating them as data-read
failures, but some of them could be backup-write errors.  Have git.py
and client.py raise distinctive errors when pack write raises IOError.

Signed-off-by: Brandon Low <lostlogic@lostlogicx.com>
lib/bup/client.py
lib/bup/git.py

index 0bb5219c4f9bc6952a0031cefb5da69cfdae3aec..6354b91a6eb0099378cb22b2cd344eb6c300451e 100644 (file)
@@ -318,8 +318,11 @@ class PackWriter_Remote(git.PackWriter):
                           sha,
                           struct.pack('!I', crc),
                           data))
-        (self._bwcount, self._bwtime) = \
-            _raw_write_bwlimit(self.file, outbuf, self._bwcount, self._bwtime)
+        try:
+            (self._bwcount, self._bwtime) = _raw_write_bwlimit(
+                    self.file, outbuf, self._bwcount, self._bwtime)
+        except IOError, e:
+            raise ClientError, e, sys.exc_info()[2]
         self.outbytes += len(data) - 20 - 4 # Don't count sha1+crc
         self.count += 1
 
index b1350532ee870516803f3dbe7a07e2fcc61c07f4..022d34716c0b349af82b6eb5ca20f3d422b42a9b 100644 (file)
@@ -2,7 +2,7 @@
 bup repositories are in Git format. This library allows us to
 interact with the Git data structures.
 """
-import os, zlib, time, subprocess, struct, stat, re, tempfile, heapq
+import os, sys, zlib, time, subprocess, struct, stat, re, tempfile, heapq
 from bup.helpers import *
 from bup import _helpers
 
@@ -557,7 +557,10 @@ class PackWriter:
         # to our hashsplit algorithm.)  f.write() does its own buffering,
         # but that's okay because we'll flush it in _end().
         oneblob = ''.join(datalist)
-        f.write(oneblob)
+        try:
+            f.write(oneblob)
+        except IOError, e:
+            raise GitError, e, sys.exc_info()[2]
         nw = len(oneblob)
         crc = zlib.crc32(oneblob) & 0xffffffff
         self._update_idx(sha, crc, nw)