Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Mar 24, 2022
2 parents 13da664 + ef752b5 commit 62139df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions picframe/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def display_is_on(self):

@display_is_on.setter
def display_is_on(self, on_off):
self.paused = not on_off
self.__viewer.display_is_on = on_off

@property
Expand Down
12 changes: 10 additions & 2 deletions picframe/image_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def get_file_info(self, file_id):
if not file_id: return None
sql = "SELECT * FROM all_data where file_id = {0}".format(file_id)
row = self.__db.execute(sql).fetchone()
if row is not None and row['last_modified'] != os.path.getmtime(row['fname']):
self.__logger.debug('Cache miss: File %s changed on disk', row['fname'])
self.__insert_file(row['fname'], file_id)
row = self.__db.execute(sql).fetchone() # description inserted in table
if row is not None and row['latitude'] is not None and row['longitude'] is not None and row['location'] is None:
if self.__get_geo_location(row['latitude'], row['longitude']):
row = self.__db.execute(sql).fetchone() # description inserted in table
Expand Down Expand Up @@ -387,8 +391,9 @@ def __get_modified_files(self, modified_folders):
return out_of_date_files


def __insert_file(self, file):
def __insert_file(self, file, file_id = None):
file_insert = "INSERT OR REPLACE INTO file(folder_id, basename, extension, last_modified) VALUES((SELECT folder_id from folder where name = ?), ?, ?, ?)"
file_update = "UPDATE file SET folder_id = (SELECT folder_id from folder where name = ?), basename = ?, extension = ?, last_modified = ? WHERE file_id = ?"
# Insert the new folder if it's not already in the table. Update the missing field separately.
folder_insert = "INSERT OR IGNORE INTO folder(name) VALUES(?)"
folder_update = "UPDATE folder SET missing = 0 where name = ?"
Expand All @@ -406,7 +411,10 @@ def __insert_file(self, file):
# Insert this file's info into the folder, file, and meta tables
self.__db.execute(folder_insert, (dir,))
self.__db.execute(folder_update, (dir,))
self.__db.execute(file_insert, (dir, base, extension.lstrip("."), mod_tm))
if file_id is None:
self.__db.execute(file_insert, (dir, base, extension.lstrip("."), mod_tm))
else:
self.__db.execute(file_update, (dir, base, extension.lstrip("."), mod_tm, file_id))
self.__db.execute(meta_insert, vals)


Expand Down

0 comments on commit 62139df

Please sign in to comment.