From 9693371a3d96ca7a8247927962c8b6273fe6e872 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 6 Dec 2017 06:09:45 +0100 Subject: [PATCH] Changed the order of code in CommandLineController to allow login when no database is present yet. Duh. --- .../CommandLineController.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java b/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java index 6e92ac1..26831c4 100644 --- a/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java +++ b/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java @@ -79,8 +79,7 @@ public class CommandLineController { try { logger.info("Initializing UserManager"); UserManager.init(client); - Database.init(client); - + UserManager user = UserManager.getInstance(); if (!CommandLineOptions.cmd_login && !user.isLoggedIn()) { @@ -93,7 +92,19 @@ public class CommandLineController { throw new RuntimeException("Account / User mismatch"); } } + + logger.debug("CommandLineOptions.cmd_login: {}", CommandLineOptions.cmd_login); + if (CommandLineOptions.cmd_login) { + cmd_login(account); + System.exit(0); + } + + // If we reach this point, we can assume that there is an account and a database can be loaded / created. + Database.init(client); + + + if (CommandLineOptions.cmd_stats) { cmd_stats(); System.exit(0); @@ -120,11 +131,7 @@ public class CommandLineController { } } - logger.debug("CommandLineOptions.cmd_login: {}", CommandLineOptions.cmd_login); - if (CommandLineOptions.cmd_login) { - cmd_login(account); - System.exit(0); - } + if (user.isLoggedIn()) { System.out.println("You are logged in as " + Utils.anonymize(user.getUserString()));