summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/rpath.py
diff options
context:
space:
mode:
authorowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2008-10-12 02:21:30 +0000
committerowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2008-10-12 02:21:30 +0000
commit3852649621c640e01ee4077f2dd77b506fe6be7f (patch)
tree2d3773ec7265cfe5c1baa861c4f75065479373fd /rdiff-backup/rdiff_backup/rpath.py
parent8e4eacb461cee6ee8b15822185553bc42e508263 (diff)
downloadrdiff-backup-3852649621c640e01ee4077f2dd77b506fe6be7f.tar.gz
Automatically resume after a failed initial backup. (Patch from Josh Nisly)
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@950 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/rpath.py')
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index b3efc8c..a75cc0e 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -372,6 +372,14 @@ def get_incfile_info(basename):
else: basestr = ".".join(dotsplit[:-2])
return (compressed, timestring, ext, basestr)
+def delete_dir_no_files(rp):
+ """Deletes the directory at rp.path if empty. Raises if the
+ directory contains files."""
+ assert rp.isdir()
+ if rp.contains_files():
+ raise RPathException("Directory contains files.")
+ rp.delete()
+
class RORPath:
"""Read Only RPath - carry information about a path
@@ -1047,6 +1055,21 @@ class RPath(RORPath):
else: self.conn.os.unlink(self.path)
self.setdata()
+ def contains_files(self):
+ """Returns true if self (or subdir) contains any regular files."""
+ log.Log("Determining if directory contains files: %s" % self.path, 7)
+ if not self.isdir():
+ return False
+ dir_entries = self.listdir()
+ for entry in dir_entries:
+ child_rp = self.append(entry)
+ if not child_rp.isdir():
+ return True
+ else:
+ if child_rp.contains_files():
+ return True
+ return False
+
def quote(self):
"""Return quoted self.path for use with os.system()"""
return '"%s"' % self.regex_chars_to_quote.sub(