瀏覽代碼

check: pick better insufficent archives matched warning from TW's merge

Marian Beermann 8 年之前
父節點
當前提交
7923088ff9
共有 4 個文件被更改,包括 13 次插入10 次删除
  1. 6 2
      src/borg/archive.py
  2. 2 3
      src/borg/repository.py
  3. 2 2
      src/borg/testsuite/archive.py
  4. 3 3
      src/borg/upgrader.py

+ 6 - 2
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:

+ 2 - 3
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)

+ 2 - 2
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 '

+ 3 - 3
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'