mirror of https://github.com/zulip/zulip.git
provision: Early-exit in template_database_status.
This is a pure refactor, and we just early-exit in case the datbase doesn't exist (knowing that that can be a bit of a lie now--see the comment I added.)
This commit is contained in:
parent
4018dcb8e7
commit
33cbb4f688
|
@ -224,7 +224,17 @@ def template_database_status(database_type: str) -> str:
|
|||
if not os.path.exists(status_dir):
|
||||
os.mkdir(status_dir)
|
||||
|
||||
if database_exists(database.database_name):
|
||||
if not database_exists(database.database_name):
|
||||
# TODO: It's possible that `database_exists` will
|
||||
# return `False` even though the database
|
||||
# exists, but we just have the wrong password,
|
||||
# probably due to changing the secrets file.
|
||||
#
|
||||
# The only problem this causes is that we waste
|
||||
# some time rebuilding the whole database, but
|
||||
# it's better to err on that side, generally.
|
||||
return 'needs_rebuild'
|
||||
|
||||
# To ensure Python evaluates all the hash tests (and thus creates the
|
||||
# hash files about the current state), we evaluate them in a
|
||||
# list and then process the result
|
||||
|
@ -257,8 +267,6 @@ def template_database_status(database_type: str) -> str:
|
|||
|
||||
return 'current'
|
||||
|
||||
return 'needs_rebuild'
|
||||
|
||||
def destroy_leaked_test_databases(expiry_time: int = 60 * 60) -> int:
|
||||
"""The logic in zerver/lib/test_runner.py tries to delete all the
|
||||
temporary test databases generated by test-backend threads, but it
|
||||
|
|
Loading…
Reference in New Issue