From 7923088ff9d1236f3a22a8e7b5641e89c155085f Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Thu, 12 Jan 2017 17:03:51 +0100 Subject: [PATCH] check: pick better insufficent archives matched warning from TW's merge --- src/borg/archive.py | 8 ++++++-- src/borg/repository.py | 5 ++--- src/borg/testsuite/archive.py | 4 ++-- src/borg/upgrader.py | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 25983a3c9..195ae8e1c 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -1360,8 +1360,12 @@ class ArchiveChecker: sort_by = sort_by.split(',') if any((first, last, prefix)): archive_infos = self.manifest.archives.list(sort_by=sort_by, prefix=prefix, first=first, last=last) - if not archive_infos: - logger.warning('--first/--last/--prefix did not match any archives') + if prefix and not archive_infos: + logger.warning('--prefix %s does not match any archives', prefix) + if first and len(archive_infos) < first: + logger.warning('--first %d archives: only found %d archives', first, len(archive_infos)) + if last and len(archive_infos) < last: + logger.warning('--last %d archives: only found %d archives', last, len(archive_infos)) else: archive_infos = self.manifest.archives.list(sort_by=sort_by) else: diff --git a/src/borg/repository.py b/src/borg/repository.py index 20ae274ef..824985da0 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -11,9 +11,6 @@ from itertools import islice import msgpack -import logging -logger = logging.getLogger(__name__) - from .constants import * # NOQA from .hashindex import NSIndex from .helpers import Error, ErrorWithTraceback, IntegrityError, format_file_size, parse_file_size @@ -27,6 +24,8 @@ from .lrucache import LRUCache from .platform import SaveFile, SyncFile, sync_dir from .crc32 import crc32 +logger = create_logger(__name__) + MAX_OBJECT_SIZE = 20 * 1024 * 1024 MAGIC = b'BORG_SEG' MAGIC_LEN = len(MAGIC) diff --git a/src/borg/testsuite/archive.py b/src/borg/testsuite/archive.py index a4f613d18..7bf3f5b63 100644 --- a/src/borg/testsuite/archive.py +++ b/src/borg/testsuite/archive.py @@ -31,8 +31,8 @@ def test_stats_basic(stats): assert stats.usize == 10 -def tests_stats_progress(stats, columns=80): - os.environ['COLUMNS'] = str(columns) +def tests_stats_progress(stats, monkeypatch, columns=80): + monkeypatch.setenv('COLUMNS', str(columns)) out = StringIO() stats.show_progress(stream=out) s = '20 B O 10 B C 10 B D 0 N ' diff --git a/src/borg/upgrader.py b/src/borg/upgrader.py index 78da849a2..28473e074 100644 --- a/src/borg/upgrader.py +++ b/src/borg/upgrader.py @@ -3,15 +3,15 @@ import os import shutil import time -import logging -logger = logging.getLogger(__name__) - from .constants import REPOSITORY_README from .helpers import get_home_dir, get_keys_dir, get_cache_dir from .helpers import ProgressIndicatorPercent from .key import KeyfileKey, KeyfileNotFoundError from .locking import Lock from .repository import Repository, MAGIC +from .logger import create_logger + +logger = create_logger(__name__) ATTIC_MAGIC = b'ATTICSEG'