|
@@ -1534,19 +1534,18 @@ class ArchiveChecker:
|
|
self.error_found = False
|
|
self.error_found = False
|
|
self.possibly_superseded = set()
|
|
self.possibly_superseded = set()
|
|
|
|
|
|
- def check(self, repository, repair=False, archive=None, first=0, last=0, sort_by='', glob=None,
|
|
|
|
|
|
+ def check(self, repository, repair=False, first=0, last=0, sort_by='', glob=None,
|
|
verify_data=False, save_space=False):
|
|
verify_data=False, save_space=False):
|
|
"""Perform a set of checks on 'repository'
|
|
"""Perform a set of checks on 'repository'
|
|
|
|
|
|
:param repair: enable repair mode, write updated or corrected data into repository
|
|
:param repair: enable repair mode, write updated or corrected data into repository
|
|
- :param archive: only check this archive
|
|
|
|
:param first/last/sort_by: only check this number of first/last archives ordered by sort_by
|
|
:param first/last/sort_by: only check this number of first/last archives ordered by sort_by
|
|
:param glob: only check archives matching this glob
|
|
:param glob: only check archives matching this glob
|
|
:param verify_data: integrity verification of data referenced by archives
|
|
:param verify_data: integrity verification of data referenced by archives
|
|
:param save_space: Repository.commit(save_space)
|
|
:param save_space: Repository.commit(save_space)
|
|
"""
|
|
"""
|
|
logger.info('Starting archive consistency check...')
|
|
logger.info('Starting archive consistency check...')
|
|
- self.check_all = archive is None and not any((first, last, glob))
|
|
|
|
|
|
+ self.check_all = not any((first, last, glob))
|
|
self.repair = repair
|
|
self.repair = repair
|
|
self.repository = repository
|
|
self.repository = repository
|
|
self.init_chunks()
|
|
self.init_chunks()
|
|
@@ -1568,7 +1567,7 @@ class ArchiveChecker:
|
|
self.error_found = True
|
|
self.error_found = True
|
|
del self.chunks[Manifest.MANIFEST_ID]
|
|
del self.chunks[Manifest.MANIFEST_ID]
|
|
self.manifest = self.rebuild_manifest()
|
|
self.manifest = self.rebuild_manifest()
|
|
- self.rebuild_refcounts(archive=archive, first=first, last=last, sort_by=sort_by, glob=glob)
|
|
|
|
|
|
+ self.rebuild_refcounts(glob=glob, first=first, last=last, sort_by=sort_by)
|
|
self.orphan_chunks_check()
|
|
self.orphan_chunks_check()
|
|
self.finish(save_space=save_space)
|
|
self.finish(save_space=save_space)
|
|
if self.error_found:
|
|
if self.error_found:
|
|
@@ -1738,7 +1737,7 @@ class ArchiveChecker:
|
|
logger.info('Manifest rebuild complete.')
|
|
logger.info('Manifest rebuild complete.')
|
|
return manifest
|
|
return manifest
|
|
|
|
|
|
- def rebuild_refcounts(self, archive=None, first=0, last=0, sort_by='', glob=None):
|
|
|
|
|
|
+ def rebuild_refcounts(self, first=0, last=0, sort_by='', glob=None):
|
|
"""Rebuild object reference counts by walking the metadata
|
|
"""Rebuild object reference counts by walking the metadata
|
|
|
|
|
|
Missing and/or incorrect data is repaired when detected
|
|
Missing and/or incorrect data is repaired when detected
|
|
@@ -1909,26 +1908,17 @@ class ArchiveChecker:
|
|
raise
|
|
raise
|
|
i += 1
|
|
i += 1
|
|
|
|
|
|
- if archive is None:
|
|
|
|
- sort_by = sort_by.split(',')
|
|
|
|
- if any((first, last, glob)):
|
|
|
|
- archive_infos = self.manifest.archives.list(sort_by=sort_by, glob=glob, first=first, last=last)
|
|
|
|
- if glob and not archive_infos:
|
|
|
|
- logger.warning('--glob-archives %s does not match any archives', glob)
|
|
|
|
- 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)
|
|
|
|
|
|
+ sort_by = sort_by.split(',')
|
|
|
|
+ if any((first, last, glob)):
|
|
|
|
+ archive_infos = self.manifest.archives.list(sort_by=sort_by, glob=glob, first=first, last=last)
|
|
|
|
+ if glob and not archive_infos:
|
|
|
|
+ logger.warning('--glob-archives %s does not match any archives', glob)
|
|
|
|
+ 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:
|
|
else:
|
|
- # we only want one specific archive
|
|
|
|
- try:
|
|
|
|
- archive_infos = [self.manifest.archives[archive]]
|
|
|
|
- except KeyError:
|
|
|
|
- logger.error("Archive '%s' not found.", archive)
|
|
|
|
- self.error_found = True
|
|
|
|
- return
|
|
|
|
|
|
+ archive_infos = self.manifest.archives.list(sort_by=sort_by)
|
|
num_archives = len(archive_infos)
|
|
num_archives = len(archive_infos)
|
|
|
|
|
|
pi = ProgressIndicatorPercent(total=num_archives, msg='Checking archives %3.1f%%', step=0.1,
|
|
pi = ProgressIndicatorPercent(total=num_archives, msg='Checking archives %3.1f%%', step=0.1,
|