fix cascading failure with the index conversion code

this resolves bug #something where the index file could not be
converted, completely breaking conversion.

it seems that, during some refactoring, the index conversion code was
completely dropped. this was missed by the unit tests because the repo
can still be opened by the constructor even though the index is
invalid, so tests need improvements there.
This commit is contained in:
Antoine Beaupré 2015-10-15 18:39:34 -04:00
parent 0e9c524266
commit c4599d8ea4
1 changed files with 4 additions and 2 deletions

View File

@ -139,12 +139,14 @@ class AtticRepositoryUpgrader(Repository):
`Cache.open()`, edit in place and then `Cache.close()` to `Cache.open()`, edit in place and then `Cache.close()` to
make sure we have locking right make sure we have locking right
""" """
caches = []
transaction_id = self.get_index_transaction_id() transaction_id = self.get_index_transaction_id()
if transaction_id is None: if transaction_id is None:
logger.warning('no index file found for repository %s' % self.path) logger.warning('no index file found for repository %s' % self.path)
else: else:
caches += [os.path.join(self.path, 'index.%d' % transaction_id).encode('utf-8')] cache = os.path.join(self.path, 'index.%d' % transaction_id).encode('utf-8')
logger.info("converting index cache %s" % cache)
if not dryrun:
AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX')
# copy of attic's get_cache_dir() # copy of attic's get_cache_dir()
attic_cache_dir = os.environ.get('ATTIC_CACHE_DIR', attic_cache_dir = os.environ.get('ATTIC_CACHE_DIR',