mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-12 09:30:27 +00:00
Move walk_path logic into archiver.py for better error handling
This commit is contained in:
parent
2a631bb3e6
commit
231c06f0d5
1 changed files with 33 additions and 18 deletions
|
@ -9,7 +9,7 @@
|
|||
from .cache import Cache
|
||||
from .keychain import Keychain
|
||||
from .helpers import location_validator, format_file_size, format_time,\
|
||||
format_file_mode, walk_path, IncludePattern, ExcludePattern, exclude_path
|
||||
format_file_mode, IncludePattern, ExcludePattern, exclude_path
|
||||
from .remote import StoreServer, RemoteStore
|
||||
|
||||
class Archiver(object):
|
||||
|
@ -74,12 +74,30 @@ def do_create(self, args):
|
|||
except IOError:
|
||||
pass
|
||||
for path in args.paths:
|
||||
for path, st in walk_path(unicode(path)):
|
||||
if exclude_path(path, args.patterns):
|
||||
continue
|
||||
self._process(archive, cache, args.patterns, unicode(path))
|
||||
archive.save(args.archive.archive)
|
||||
cache.save()
|
||||
return self.exit_code
|
||||
|
||||
def _process(self, archive, cache, patterns, path):
|
||||
if exclude_path(path, patterns):
|
||||
return
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
except OSError, e:
|
||||
self.print_error('%s: %s', path, e)
|
||||
return
|
||||
self.print_verbose(path)
|
||||
if stat.S_ISDIR(st.st_mode):
|
||||
archive.process_dir(path, st)
|
||||
try:
|
||||
entries = os.listdir(path)
|
||||
except OSError, e:
|
||||
self.print_error('%s: %s', path, e)
|
||||
else:
|
||||
for filename in entries:
|
||||
self._process(archive, cache, patterns,
|
||||
os.path.join(path, filename))
|
||||
elif stat.S_ISLNK(st.st_mode):
|
||||
archive.process_symlink(path, st)
|
||||
elif stat.S_ISFIFO(st.st_mode):
|
||||
|
@ -91,9 +109,6 @@ def do_create(self, args):
|
|||
self.print_error('%s: %s', path, e)
|
||||
else:
|
||||
self.print_error('Unknown file type: %s', path)
|
||||
archive.save(args.archive.archive)
|
||||
cache.save()
|
||||
return self.exit_code
|
||||
|
||||
def do_extract(self, args):
|
||||
store = self.open_store(args.archive)
|
||||
|
|
Loading…
Reference in a new issue