зеркало из https://github.com/mozilla/bugbug.git
Remove versioning support, as we are not really using it (#359)
This commit is contained in:
Родитель
33f5bbf2c0
Коммит
a779560d37
|
@ -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 = [
|
||||
|
|
34
bugbug/db.py
34
bugbug/db.py
|
@ -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))
|
||||
|
|
Загрузка…
Ссылка в новой задаче