diff --git a/darc/archive.py b/darc/archive.py index 688085ddc..8f03b151d 100644 --- a/darc/archive.py +++ b/darc/archive.py @@ -186,19 +186,6 @@ class Archive(object): os.makedirs(path) if restore_attrs: self.restore_attrs(path, item) - elif stat.S_ISFIFO(mode): - if not os.path.exists(os.path.dirname(path)): - os.makedirs(os.path.dirname(path)) - os.mkfifo(path) - self.restore_attrs(path, item) - elif stat.S_ISLNK(mode): - if not os.path.exists(os.path.dirname(path)): - os.makedirs(os.path.dirname(path)) - source = item['source'] - if os.path.exists(path): - os.unlink(path) - os.symlink(source, path) - self.restore_attrs(path, item, symlink=True) elif stat.S_ISREG(mode): if not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) @@ -231,7 +218,22 @@ class Archive(object): else: for i, (id, size, csize) in enumerate(item['chunks']): self.store.get(id, callback=extract_cb, callback_data=(id, i)) - + elif stat.S_ISFIFO(mode): + if not os.path.exists(os.path.dirname(path)): + os.makedirs(os.path.dirname(path)) + os.mkfifo(path) + self.restore_attrs(path, item) + elif stat.S_ISLNK(mode): + if not os.path.exists(os.path.dirname(path)): + os.makedirs(os.path.dirname(path)) + source = item['source'] + if os.path.exists(path): + os.unlink(path) + os.symlink(source, path) + self.restore_attrs(path, item, symlink=True) + elif stat.S_ISCHR(mode) or stat.S_ISBLK(mode): + os.mknod(path, item['mode'], item['dev']) + self.restore_attrs(path, item) else: raise Exception('Unknown archive item type %r' % item['mode']) @@ -328,12 +330,7 @@ class Archive(object): pass return item - def process_dir(self, path, st): - item = {'path': path.lstrip('/\\:')} - item.update(self.stat_attrs(st, path)) - self.add_item(item) - - def process_fifo(self, path, st): + def process_item(self, path, st): item = {'path': path.lstrip('/\\:')} item.update(self.stat_attrs(st, path)) self.add_item(item) diff --git a/darc/archiver.py b/darc/archiver.py index 05523b761..662950584 100644 --- a/darc/archiver.py +++ b/darc/archiver.py @@ -130,7 +130,7 @@ class Archiver(object): return self.print_verbose(path) if stat.S_ISDIR(st.st_mode): - archive.process_dir(path, st) + archive.process_item(path, st) try: entries = os.listdir(path) except OSError, e: @@ -139,10 +139,10 @@ class Archiver(object): for filename in sorted(entries): self._process(archive, cache, patterns, skip_inodes, os.path.join(path, filename), restrict_dev) + elif stat.S_ISFIFO(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISBLK(st.st_mode): + archive.process_item(path, st) elif stat.S_ISLNK(st.st_mode): archive.process_symlink(path, st) - elif stat.S_ISFIFO(st.st_mode): - archive.process_fifo(path, st) elif stat.S_ISREG(st.st_mode): try: archive.process_file(path, st, cache)