Skip to content

Commit

Permalink
prevent double exif entries: check case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
outdoorbits committed Jan 31, 2025
1 parent 4a60eef commit 5184ebe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/lib_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self,setup,log,MountPoint):
res = self.__cur.execute('PRAGMA table_info(EXIF_DATA);')
Lines = res.fetchall()
for Line in Lines:
self.__EXIF_KnownColumnsList.append(Line[1])
self.__EXIF_KnownColumnsList.append(Line[1].lower())

def __dbCreateUpgrade(self):
# define database, append lines for updates, do not change existing lines!
Expand Down Expand Up @@ -128,7 +128,8 @@ def dbInsertImage(self, ImageFileSubpathFilename):
EXIF_List = []

# get image record out of exif data
ImageRecord = {}
ImageRecord = {}
ImageRecord_lower = [] # for case insensitive check for known fields

for EXIF in EXIF_List:

Expand All @@ -153,7 +154,7 @@ def dbInsertImage(self, ImageFileSubpathFilename):
continue

## prevent doubles
if EXIF_Field in ImageRecord:
if EXIF_Field.lower() in ImageRecord_lower:
continue

if not EXIF_Field in ['File_Name','Directory']:
Expand All @@ -164,6 +165,7 @@ def dbInsertImage(self, ImageFileSubpathFilename):
EXIF_Value = re.sub('[^a-zA-Z0-9_\-+\.,:;\ &#/()\[\]]<>', '_', EXIF_Value)

ImageRecord[EXIF_Field] = EXIF_Value
ImageRecord_lower.append(EXIF_Field.lower())

# define/overwrite elements of ImageRecord
## file: name and directory
Expand Down Expand Up @@ -197,7 +199,7 @@ def dbInsertImage(self, ImageFileSubpathFilename):

for EXIF_Field in ImageRecord.keys():
# add column to the table if doesn't exist
if not EXIF_Field in self.__EXIF_KnownColumnsList:
if not EXIF_Field.lower() in self.__EXIF_KnownColumnsList:
self.__cur.execute(f"alter table EXIF_DATA add column '{EXIF_Field}' text;")
self.__EXIF_KnownColumnsList.append(EXIF_Field)

Expand Down

0 comments on commit 5184ebe

Please sign in to comment.