Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix database move message #5506

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions kalite/distributed/management/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,32 +332,29 @@ def handle(self, *args, **options):

install_clean = not database_exists

if database_file:
if not database_exists:
install_clean = True
if database_exists:
# We found an existing database file. By default,
# we will upgrade it; users really need to work hard
# to delete the file (but it's possible, which is nice).
logger.info(
"-------------------------------------------------------------------\n"
"WARNING: Database file already exists!\n"
"-------------------------------------------------------------------"
)
if not options["interactive"] \
or raw_input_yn("Keep database file and upgrade to KA Lite version %s? " % VERSION) \
or not raw_input_yn("Remove database file '%s' now? " % database_file) \
or not raw_input_yn("WARNING: all data will be lost! Are you sure? "):

This comment was marked as spam.

install_clean = False
logger.info("Upgrading database to KA Lite version %s" % VERSION)
else:
# We found an existing database file. By default,
# we will upgrade it; users really need to work hard
# to delete the file (but it's possible, which is nice).
install_clean = True
logger.info("OK. We will run a clean install; ")
# After all, don't delete--just move.
logger.info(
"-------------------------------------------------------------------\n"
"WARNING: Database file already exists!\n"
"-------------------------------------------------------------------"
"the database file will be moved to a deletable "
"location."
)
if not options["interactive"] \
or raw_input_yn("Keep database file and upgrade to KA Lite version %s? " % VERSION) \
or not raw_input_yn("Remove database file '%s' now? " % database_file) \
or not raw_input_yn("WARNING: all data will be lost! Are you sure? "):
install_clean = False
logger.info("Upgrading database to KA Lite version %s" % VERSION)
else:
install_clean = True
logger.info("OK. We will run a clean install; ")
# After all, don't delete--just move.
logger.info(
"the database file will be moved to a deletable "
"location."
)

if not install_clean and not database_file:
# Make sure that, for non-sqlite installs, the database exists.
Expand Down Expand Up @@ -398,7 +395,7 @@ def handle(self, *args, **options):
########################

# Move database file (if exists)
if install_clean and database_file and os.path.exists(database_file):
if install_clean and database_file and database_exists:

This comment was marked as spam.

if not settings.DB_TEMPLATE_DEFAULT or database_file != settings.DB_TEMPLATE_DEFAULT:
# This is an overwrite install; destroy the old db
dest_file = tempfile.mkstemp()[1]
Expand Down