From 2eaac9e996a11b69ad8b472e4c44f08db00b3dff Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 14 Nov 2021 15:43:50 -0800 Subject: [PATCH] Return early from ephemeral so we can dedent this code. --- etiquette/photodb.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index c882a0c..6afcf42 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -1601,16 +1601,18 @@ class PhotoDB( if self.ephemeral: existing_database = False self.sql = sqlite3.connect(':memory:') - else: - self.database_filepath = self.data_directory.with_child(constants.DEFAULT_DBNAME) - existing_database = self.database_filepath.exists + self._first_time_setup() + return - if not existing_database and not create: - msg = f'"{self.database_filepath.absolute_path}" does not exist and create is off.' - raise FileNotFoundError(msg) + self.database_filepath = self.data_directory.with_child(constants.DEFAULT_DBNAME) + existing_database = self.database_filepath.exists - self.data_directory.makedirs(exist_ok=True) - self.sql = sqlite3.connect(self.database_filepath.absolute_path) + if not existing_database and not create: + msg = f'"{self.database_filepath.absolute_path}" does not exist and create is off.' + raise FileNotFoundError(msg) + + self.data_directory.makedirs(exist_ok=True) + self.sql = sqlite3.connect(self.database_filepath.absolute_path) if existing_database: if not skip_version_check: