mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-31 03:31:41 +00:00
Rename input_io*() -> backup_io*()
This commit is contained in:
parent
93b740adee
commit
5e260fdfda
3 changed files with 17 additions and 17 deletions
|
@ -46,7 +46,7 @@
|
||||||
flags_noatime = flags_normal | getattr(os, 'O_NOATIME', 0)
|
flags_noatime = flags_normal | getattr(os, 'O_NOATIME', 0)
|
||||||
|
|
||||||
|
|
||||||
class InputOSError(Exception):
|
class BackupOSError(Exception):
|
||||||
"""Wrapper for OSError raised while accessing input files."""
|
"""Wrapper for OSError raised while accessing input files."""
|
||||||
def __init__(self, os_error):
|
def __init__(self, os_error):
|
||||||
self.os_error = os_error
|
self.os_error = os_error
|
||||||
|
@ -59,18 +59,18 @@ def __str__(self):
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def input_io():
|
def backup_io():
|
||||||
"""Context manager changing OSError to InputOSError."""
|
"""Context manager changing OSError to BackupOSError."""
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
except OSError as os_error:
|
except OSError as os_error:
|
||||||
raise InputOSError(os_error) from os_error
|
raise BackupOSError(os_error) from os_error
|
||||||
|
|
||||||
|
|
||||||
def input_io_iter(iterator):
|
def input_io_iter(iterator):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
with input_io():
|
with backup_io():
|
||||||
item = next(iterator)
|
item = next(iterator)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return
|
return
|
||||||
|
@ -496,13 +496,13 @@ def stat_attrs(self, st, path):
|
||||||
}
|
}
|
||||||
if self.numeric_owner:
|
if self.numeric_owner:
|
||||||
item[b'user'] = item[b'group'] = None
|
item[b'user'] = item[b'group'] = None
|
||||||
with input_io():
|
with backup_io():
|
||||||
xattrs = xattr.get_all(path, follow_symlinks=False)
|
xattrs = xattr.get_all(path, follow_symlinks=False)
|
||||||
if xattrs:
|
if xattrs:
|
||||||
item[b'xattrs'] = StableDict(xattrs)
|
item[b'xattrs'] = StableDict(xattrs)
|
||||||
if has_lchflags and st.st_flags:
|
if has_lchflags and st.st_flags:
|
||||||
item[b'bsdflags'] = st.st_flags
|
item[b'bsdflags'] = st.st_flags
|
||||||
with input_io():
|
with backup_io():
|
||||||
acl_get(path, item, st, self.numeric_owner)
|
acl_get(path, item, st, self.numeric_owner)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ def process_file(self, path, st, cache, ignore_inode=False):
|
||||||
item = {b'path': safe_path}
|
item = {b'path': safe_path}
|
||||||
# Only chunkify the file if needed
|
# Only chunkify the file if needed
|
||||||
if chunks is None:
|
if chunks is None:
|
||||||
with input_io():
|
with backup_io():
|
||||||
fh = Archive._open_rb(path)
|
fh = Archive._open_rb(path)
|
||||||
with os.fdopen(fh, 'rb') as fd:
|
with os.fdopen(fh, 'rb') as fd:
|
||||||
chunks = []
|
chunks = []
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
from .repository import Repository
|
from .repository import Repository
|
||||||
from .cache import Cache
|
from .cache import Cache
|
||||||
from .key import key_creator, RepoKey, PassphraseKey
|
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
|
from .remote import RepositoryServer, RemoteRepository, cache_if_remote
|
||||||
|
|
||||||
has_lchflags = hasattr(os, 'lchflags')
|
has_lchflags = hasattr(os, 'lchflags')
|
||||||
|
@ -198,7 +198,7 @@ def create_inner(archive, cache):
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
try:
|
try:
|
||||||
status = archive.process_stdin(path, cache)
|
status = archive.process_stdin(path, cache)
|
||||||
except InputOSError as e:
|
except BackupOSError as e:
|
||||||
status = 'E'
|
status = 'E'
|
||||||
self.print_warning('%s: %s', path, e)
|
self.print_warning('%s: %s', path, e)
|
||||||
else:
|
else:
|
||||||
|
@ -281,7 +281,7 @@ def _process(self, archive, cache, matcher, exclude_caches, exclude_if_present,
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
try:
|
try:
|
||||||
status = archive.process_file(path, st, cache, self.ignore_inode)
|
status = archive.process_file(path, st, cache, self.ignore_inode)
|
||||||
except InputOSError as e:
|
except BackupOSError as e:
|
||||||
status = 'E'
|
status = 'E'
|
||||||
self.print_warning('%s: %s', path, e)
|
self.print_warning('%s: %s', path, e)
|
||||||
elif stat.S_ISDIR(st.st_mode):
|
elif stat.S_ISDIR(st.st_mode):
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ..archive import Archive, CacheChunkBuffer, RobustUnpacker, valid_msgpacked_dict, ITEM_KEYS
|
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 ..key import PlaintextKey
|
||||||
from ..helpers import Manifest
|
from ..helpers import Manifest
|
||||||
from . import BaseTestCase
|
from . import BaseTestCase
|
||||||
|
@ -148,13 +148,13 @@ def test_key_length_msgpacked_items():
|
||||||
assert valid_msgpacked_dict(msgpack.packb(data), item_keys_serialized)
|
assert valid_msgpacked_dict(msgpack.packb(data), item_keys_serialized)
|
||||||
|
|
||||||
|
|
||||||
def test_input_io():
|
def test_backup_io():
|
||||||
with pytest.raises(InputOSError):
|
with pytest.raises(BackupOSError):
|
||||||
with input_io():
|
with backup_io():
|
||||||
raise OSError(123)
|
raise OSError(123)
|
||||||
|
|
||||||
|
|
||||||
def test_input_io_iter():
|
def test_backup_io_iter():
|
||||||
class Iterator:
|
class Iterator:
|
||||||
def __init__(self, exc):
|
def __init__(self, exc):
|
||||||
self.exc = exc
|
self.exc = exc
|
||||||
|
@ -163,7 +163,7 @@ def __next__(self):
|
||||||
raise self.exc()
|
raise self.exc()
|
||||||
|
|
||||||
oserror_iterator = Iterator(OSError)
|
oserror_iterator = Iterator(OSError)
|
||||||
with pytest.raises(InputOSError):
|
with pytest.raises(BackupOSError):
|
||||||
for _ in input_io_iter(oserror_iterator):
|
for _ in input_io_iter(oserror_iterator):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue