From 6fa3fef60bf51b664da9d13b174137a32a4ee8a0 Mon Sep 17 00:00:00 2001 From: bescoto Date: Sat, 5 Nov 2005 02:54:03 +0000 Subject: Fix for quoted filenames too long git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@670 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/rdiff_backup/backup.py | 44 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'rdiff-backup/rdiff_backup/backup.py') diff --git a/rdiff-backup/rdiff_backup/backup.py b/rdiff-backup/rdiff_backup/backup.py index f92d163..dfe21ac 100644 --- a/rdiff-backup/rdiff_backup/backup.py +++ b/rdiff-backup/rdiff_backup/backup.py @@ -477,14 +477,27 @@ class PatchITRB(rorpiter.ITRBranch): self.cached_rp = self.basis_root_rp.new_index(index) return self.cached_rp + def check_long_name(self, func, *args): + """Execute function, checking for ENAMETOOLONG error""" + try: result = func(*args) + except OSError, exc: + if (errno.errorcode.has_key(exc[0]) and + errno.errorcode[exc[0]] == 'ENAMETOOLONG'): + self.error_handler(exc, args[0]) + return None + else: raise + return result + def can_fast_process(self, index, diff_rorp): """True if diff_rorp and mirror are not directories""" - rp = self.get_rp_from_root(index) - return not diff_rorp.isdir() and not rp.isdir() + rp = self.check_long_name(self.get_rp_from_root, index) + # filename too long error qualifies (hack) + return not rp or (not diff_rorp.isdir() and not rp.isdir()) def fast_process(self, index, diff_rorp): """Patch base_rp with diff_rorp (case where neither is directory)""" - rp = self.get_rp_from_root(index) + rp = self.check_long_name(self.get_rp_from_root, index) + if not rp: return tf = TempFile.new(rp) if self.patch_to_temp(rp, diff_rorp, tf): if tf.lstat(): @@ -633,23 +646,14 @@ class IncrementITRB(PatchITRB): self.cached_incrp = self.inc_root_rp.new_index(index) return self.cached_incrp - def inc_with_checking(self, new, old, inc_rp): - """Produce increment taking new to old checking for errors""" - try: inc = increment.Increment(new, old, inc_rp) - except OSError, exc: - if (errno.errorcode.has_key(exc[0]) and - errno.errorcode[exc[0]] == 'ENAMETOOLONG'): - self.error_handler(exc, old) - return None - else: raise - return inc - def fast_process(self, index, diff_rorp): """Patch base_rp with diff_rorp and write increment (neither is dir)""" - rp = self.get_rp_from_root(index) + rp = self.check_long_name(self.get_rp_from_root, index) + if not rp: return tf = TempFile.new(rp) if self.patch_to_temp(rp, diff_rorp, tf): - inc = self.inc_with_checking(tf, rp, self.get_incrp(index)) + inc = self.check_long_name(increment.Increment, + tf, rp, self.get_incrp(index)) if inc is not None: self.CCPP.set_inc(index, inc) if inc.isreg(): @@ -669,14 +673,14 @@ class IncrementITRB(PatchITRB): base_rp = self.base_rp = self.get_rp_from_root(index) assert diff_rorp.isdir() or base_rp.isdir() if diff_rorp.isdir(): - inc = self.inc_with_checking(diff_rorp, base_rp, - self.get_incrp(index)) + inc = self.check_long_name(increment.Increment, + diff_rorp, base_rp, self.get_incrp(index)) if inc and inc.isreg(): inc.fsync_with_dir() # must write inc before rp changed self.prepare_dir(diff_rorp, base_rp) elif self.set_dir_replacement(diff_rorp, base_rp): - inc = self.inc_with_checking(self.dir_replacement, base_rp, - self.get_incrp(index)) + inc = self.check_long_name(increment.Increment, + self.dir_replacement, base_rp, self.get_incrp(index)) if inc: self.CCPP.set_inc(index, inc) self.CCPP.flag_success(index) -- cgit v1.2.1