Remove versioning support, as we are not really using it (#359)

This commit is contained in:
Marco 2019-05-09 11:12:30 +02:00 коммит произвёл GitHub
Родитель 33f5bbf2c0
Коммит a779560d37
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 7 добавлений и 38 удалений

Просмотреть файл

@ -16,7 +16,6 @@ BUGS_DB = "data/bugs.json"
db.register(
BUGS_DB,
"https://index.taskcluster.net/v1/task/project.relman.bugbug.data_bugs.latest/artifacts/public/bugs.json.xz",
"v1",
)
ATTACHMENT_INCLUDE_FIELDS = [

Просмотреть файл

@ -17,11 +17,9 @@ import zstandard
DATABASES = {}
VER_PATH = "data/DB_VERSION.json"
def register(path, url, version):
DATABASES[path] = {"url": url, "version": version}
def register(path, url):
DATABASES[path] = {"url": url}
# Create DB parent directory.
parent_dir = os.path.dirname(path)
@ -32,21 +30,19 @@ def register(path, url, version):
# Download and extract databases.
def download():
for path, info in DATABASES.items():
if os.path.exists(path) and not is_outdated(path):
if os.path.exists(path):
continue
xz_path = f"{path}.xz"
# Only download if the xz file is not there yet.
if not os.path.exists(xz_path) or is_outdated(path):
if not os.path.exists(xz_path):
urlretrieve(DATABASES[path]["url"], xz_path)
with open(path, "wb") as output_f:
with lzma.open(xz_path) as input_f:
shutil.copyfileobj(input_f, output_f)
update_ver_file(path)
class Store:
def __init__(self, fh):
@ -157,25 +153,3 @@ def delete(path, match):
os.unlink(path)
os.rename(new_path, path)
def is_outdated(path):
if not os.path.exists(VER_PATH):
return True
with open(VER_PATH) as db:
ver = json.load(db)
return DATABASES[path]["version"] != ver[path] if path in ver else True
def update_ver_file(db_path):
if os.path.exists(VER_PATH):
with open(VER_PATH) as db:
ver_dict = json.load(db)
else:
ver_dict = {}
ver_dict[db_path] = DATABASES[db_path]["version"]
with open(VER_PATH, "w") as db:
json.dump(ver_dict, db)

Просмотреть файл

@ -24,7 +24,6 @@ COMMITS_DB = "data/commits.json"
db.register(
COMMITS_DB,
"https://index.taskcluster.net/v1/task/project.relman.bugbug.data_commits.latest/artifacts/public/commits.json.xz",
"v1",
)
path_to_component = {}

Просмотреть файл

@ -8,7 +8,7 @@ import shutil
import pytest
from bugbug import bugzilla, db, repository
from bugbug import bugzilla, repository
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "fixtures")
@ -25,9 +25,6 @@ def mock_data(tmp_path_factory):
os.chdir(tmp_path)
for f in DBs:
db.update_ver_file(os.path.join("data", f))
@pytest.fixture
def get_fixture_path():

Просмотреть файл

@ -16,7 +16,7 @@ def mock_db(tmp_path):
db_name += f".{db_compression}"
db_path = tmp_path / db_name
db.register(db_path, "https://alink", 1)
db.register(db_path, "https://alink")
return db_path
return register_db
@ -78,7 +78,7 @@ def test_unregistered_db(tmp_path):
)
def test_bad_format_compression(tmp_path, db_name):
db_path = tmp_path / db_name
db.register(db_path, "https://alink", 1)
db.register(db_path, "https://alink")
with pytest.raises(AssertionError):
db.write(db_path, range(7))