From 1f6dc55eab6f2859746c9fd2fcffe3d09c517d40 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 26 Mar 2017 14:03:39 +0200 Subject: [PATCH] simplify char/block device file dispatching --- src/borg/archive.py | 9 +++------ src/borg/archiver.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 4e331a776..d602faf45 100644 --- a/src/borg/archive.py +++ b/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 diff --git a/src/borg/archiver.py b/src/borg/archiver.py index e73aaf2dd..26cacba34 100644 --- a/src/borg/archiver.py +++ b/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):