1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-30 11:11:28 +00:00

Rename input_io*() -> backup_io*()

This commit is contained in:
Marian Beermann 2016-07-01 00:13:53 +02:00
parent 93b740adee
commit 5e260fdfda
3 changed files with 17 additions and 17 deletions

View file

@ -46,7 +46,7 @@
flags_noatime = flags_normal | getattr(os, 'O_NOATIME', 0)
class InputOSError(Exception):
class BackupOSError(Exception):
"""Wrapper for OSError raised while accessing input files."""
def __init__(self, os_error):
self.os_error = os_error
@ -59,18 +59,18 @@ def __str__(self):
@contextmanager
def input_io():
"""Context manager changing OSError to InputOSError."""
def backup_io():
"""Context manager changing OSError to BackupOSError."""
try:
yield
except OSError as os_error:
raise InputOSError(os_error) from os_error
raise BackupOSError(os_error) from os_error
def input_io_iter(iterator):
while True:
try:
with input_io():
with backup_io():
item = next(iterator)
except StopIteration:
return
@ -496,13 +496,13 @@ def stat_attrs(self, st, path):
}
if self.numeric_owner:
item[b'user'] = item[b'group'] = None
with input_io():
with backup_io():
xattrs = xattr.get_all(path, follow_symlinks=False)
if xattrs:
item[b'xattrs'] = StableDict(xattrs)
if has_lchflags and st.st_flags:
item[b'bsdflags'] = st.st_flags
with input_io():
with backup_io():
acl_get(path, item, st, self.numeric_owner)
return item
@ -586,7 +586,7 @@ def process_file(self, path, st, cache, ignore_inode=False):
item = {b'path': safe_path}
# Only chunkify the file if needed
if chunks is None:
with input_io():
with backup_io():
fh = Archive._open_rb(path)
with os.fdopen(fh, 'rb') as fd:
chunks = []

View file

@ -29,7 +29,7 @@
from .repository import Repository
from .cache import Cache
from .key import key_creator, RepoKey, PassphraseKey
from .archive import input_io, InputOSError, Archive, ArchiveChecker, CHUNKER_PARAMS
from .archive import backup_io, BackupOSError, Archive, ArchiveChecker, CHUNKER_PARAMS
from .remote import RepositoryServer, RemoteRepository, cache_if_remote
has_lchflags = hasattr(os, 'lchflags')
@ -198,7 +198,7 @@ def create_inner(archive, cache):
if not dry_run:
try:
status = archive.process_stdin(path, cache)
except InputOSError as e:
except BackupOSError as e:
status = 'E'
self.print_warning('%s: %s', path, e)
else:
@ -281,7 +281,7 @@ def _process(self, archive, cache, matcher, exclude_caches, exclude_if_present,
if not dry_run:
try:
status = archive.process_file(path, st, cache, self.ignore_inode)
except InputOSError as e:
except BackupOSError as e:
status = 'E'
self.print_warning('%s: %s', path, e)
elif stat.S_ISDIR(st.st_mode):

View file

@ -5,7 +5,7 @@
import pytest
from ..archive import Archive, CacheChunkBuffer, RobustUnpacker, valid_msgpacked_dict, ITEM_KEYS
from ..archive import InputOSError, input_io, input_io_iter
from ..archive import BackupOSError, backup_io, input_io_iter
from ..key import PlaintextKey
from ..helpers import Manifest
from . import BaseTestCase
@ -148,13 +148,13 @@ def test_key_length_msgpacked_items():
assert valid_msgpacked_dict(msgpack.packb(data), item_keys_serialized)
def test_input_io():
with pytest.raises(InputOSError):
with input_io():
def test_backup_io():
with pytest.raises(BackupOSError):
with backup_io():
raise OSError(123)
def test_input_io_iter():
def test_backup_io_iter():
class Iterator:
def __init__(self, exc):
self.exc = exc
@ -163,7 +163,7 @@ def __next__(self):
raise self.exc()
oserror_iterator = Iterator(OSError)
with pytest.raises(InputOSError):
with pytest.raises(BackupOSError):
for _ in input_io_iter(oserror_iterator):
pass