Skip to content

Commit

Permalink
Merge pull request #113 from helgeerbe/dev
Browse files Browse the repository at this point in the history
slight simplification of SQL, reverting to original INSERT OR IGNORE
  • Loading branch information
helgeerbe authored May 5, 2021
2 parents 39652b7 + a90aaaa commit 5880c39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions picframe/image_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def __get_modified_files(self, modified_folders):
def __insert_file(self, file):
file_insert = "INSERT OR REPLACE INTO file(folder_id, basename, extension, last_modified) VALUES((SELECT folder_id from folder where name = ?), ?, ?, ?)"
# Insert the new folder if it's not already in the table. Update the missing field separately.
folder_insert = "INSERT INTO folder(name) SELECT ? WHERE NOT EXISTS(SELECT 1 FROM folder WHERE name = ?)"
folder_insert = "INSERT OR IGNORE INTO folder(name) VALUES(?)"
folder_update = "UPDATE folder SET missing = 0 where name = ?"

mod_tm = os.path.getmtime(file)
Expand All @@ -346,7 +346,7 @@ def __insert_file(self, file):
vals.insert(0, file)

# Insert this file's info into the folder, file, and meta tables
self.__db.execute(folder_insert, (dir,dir))
self.__db.execute(folder_insert, (dir,))
self.__db.execute(folder_update, (dir,))
self.__db.execute(file_insert, (dir, base, extension.lstrip("."), mod_tm))
self.__db.execute(meta_insert, vals)
Expand Down

0 comments on commit 5880c39

Please sign in to comment.