Skip to content

Commit

Permalink
Fix for #1395
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Jan 22, 2024
1 parent c7c24f4 commit a58f168
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion osxphotos/export_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ExportDBTemp",
]

OSXPHOTOS_EXPORTDB_VERSION = "9.0"
OSXPHOTOS_EXPORTDB_VERSION = "9.1"
OSXPHOTOS_ABOUT_STRING = f"Created by osxphotos version {__version__} (https://github.com/RhetTbull/osxphotos) on {datetime.datetime.now()}"

# max retry attempts for methods which use tenacity.retry
Expand Down Expand Up @@ -703,6 +703,10 @@ def _create_or_migrate_db_tables(
# add history table
self._migrate_8_0_to_9_0(conn)

if version_info[1] < "9.1" and version >= "9.1":
# add history table
self._migrate_9_0_to_9_1(conn)

with self.lock:
conn.execute("VACUUM;")
conn.commit()
Expand Down Expand Up @@ -1000,6 +1004,21 @@ def _migrate_8_0_to_9_0(self, conn: sqlite3.Connection):

conn.commit()

def _migrate_9_0_to_9_1(self, conn: sqlite3.Connection):
"""Add history index"""
with self.lock:
c = conn.cursor()

# add index to the history_path table
c.execute(
""" CREATE UNIQUE INDEX IF NOT EXISTS
idx_history_path_filepath_normalized
ON history_path (filepath_normalized);
"""
)

conn.commit()

def _perform_db_maintenance(self, conn: sqlite3.Connection):
"""Perform database maintenance"""
if self.version < "6.0":
Expand Down

0 comments on commit a58f168

Please sign in to comment.