Browse Source

simplify char/block device file dispatching

Thomas Waldmann 8 years ago
parent
commit
1f6dc55eab
2 changed files with 11 additions and 8 deletions
  1. 3 6
      src/borg/archive.py
  2. 8 2
      src/borg/archiver.py

+ 3 - 6
src/borg/archive.py

@@ -864,14 +864,11 @@ Utilization of max. archive size: {csize_max:.0%}
             item.update(self.stat_attrs(st, path))
             return status
 
-    def process_dev(self, path, st):
-        with self.create_helper(path, st, None) as (item, status, hardlinked, hardlink_master):  # no status yet
+    def process_dev(self, path, st, dev_type):
+        with self.create_helper(path, st, dev_type) as (item, status, hardlinked, hardlink_master):  # char/block device
             item.rdev = st.st_rdev
             item.update(self.stat_attrs(st, path))
-            if stat.S_ISCHR(st.st_mode):
-                return 'c'  # char device
-            elif stat.S_ISBLK(st.st_mode):
-                return 'b'  # block device
+            return status
 
     def process_symlink(self, path, st):
         with self.create_helper(path, st, 's') as (item, status, hardlinked, hardlink_master):  # symlink

+ 8 - 2
src/borg/archiver.py

@@ -562,10 +562,16 @@ class Archiver:
                         status = archive.process_fifo(path, st)
                     else:
                         status = archive.process_file(path, st, cache)
-            elif stat.S_ISCHR(st.st_mode) or stat.S_ISBLK(st.st_mode):
+            elif stat.S_ISCHR(st.st_mode):
                 if not dry_run:
                     if not read_special:
-                        status = archive.process_dev(path, st)
+                        status = archive.process_dev(path, st, 'c')
+                    else:
+                        status = archive.process_file(path, st, cache)
+            elif stat.S_ISBLK(st.st_mode):
+                if not dry_run:
+                    if not read_special:
+                        status = archive.process_dev(path, st, 'b')
                     else:
                         status = archive.process_file(path, st, cache)
             elif stat.S_ISSOCK(st.st_mode):