Skip to content

Commit

Permalink
Fixed findings from online review
Browse files Browse the repository at this point in the history
  • Loading branch information
ckunki committed Oct 9, 2023
1 parent f9f65dc commit beed26e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions secret-store/secret_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ def connection(self) -> sqlcipher.Connection:
return self._con

def _initialize(self, db_file_found: bool) -> None:
if db_file_found:
self._verify_access()
return

def create_table(table: Table) -> None:
_logger.info(f'Creating table "{table.name}".')
columns = " ,".join(table.columns)
with self._cursor() as cur:
cur.execute(f"CREATE TABLE {table.name} (key, {columns})")

if db_file_found:
self._verify_access()
return
for table in (SECRETS_TABLE, CONFIG_ITEMS_TABLE):
create_table(table)

Expand Down Expand Up @@ -97,8 +98,11 @@ def _cursor(self) -> sqlcipher.Cursor:
cur = self.connection().cursor()
try:
yield cur
finally:
self.connection().commit()
except:
self.connection().rollback()
raise
finally:
cur.close()

def _save_data(self, table: Table, key: str, data: list[str]) -> "Secrets":
Expand Down

0 comments on commit beed26e

Please sign in to comment.