Skip to content

Commit

Permalink
Workaround potential backwards incompat with gnudbm usage
Browse files Browse the repository at this point in the history
The earlier commit, 9869bfe, switched
the dbm usage of the file repository to always use gnu dbm. However this
is a potentially backwards incompatible change. If someone has a
repository that was initialized with a dbm file other than gnu dbm.
This commit addresses this by catching the error raised by gdbm in that
case and recreating the times database with gnudbm. The data will be
lost, but since only 1 previous timing record is kept and it's only used
for scheduler optimization this is not an issue.
  • Loading branch information
mtreinish committed Feb 14, 2017
1 parent 9869bfe commit 97a5270
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions stestr/repository/file.py
Expand Up @@ -12,10 +12,10 @@

"""Persistent storage of test results."""

from io import BytesIO
import errno
from io import BytesIO
from operator import methodcaller
import os.path
import os
import sys
import tempfile

Expand Down Expand Up @@ -134,7 +134,11 @@ def _get_inserter(self, partial):
def _get_test_times(self, test_ids):
# May be too slow, but build and iterate.
# 'c' because an existing repo may be missing a file.
db = dbm.open(self._path('times.dbm'), 'c')
try:
db = dbm.open(self._path('times.dbm'), 'c')
except dbm.error:
os.remove(self._path('times.dbm'))
db = dbm.open(self._path('times.dbm'), 'c')
try:
result = {}
for test_id in test_ids:
Expand Down

0 comments on commit 97a5270

Please sign in to comment.