Skip to content

Commit

Permalink
fix: dictionary mtime not updated correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Crissium committed Feb 2, 2024
1 parent 634348e commit a9bd2b9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/app/dictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def _load_dictionary(self, dictionary_info: dict) -> None:
db_manager.delete_dictionary(dictionary_info['dictionary_name'])
logger.info(f'Entries of {dictionary_info["dictionary_display_name"]} deleted from database,'
'ready for re-indexing.')
self.settings.update_dictionary_modification_time(dictionary_info['dictionary_name'],
cur_time_modified)

match dictionary_info['dictionary_format']:
case 'MDict (.mdx)':
self._dictionaries[dictionary_info['dictionary_name']] =\
Expand Down Expand Up @@ -98,6 +97,12 @@ def _load_dictionary(self, dictionary_info: dict) -> None:
case _:
raise ValueError(f'Dictionary format {dictionary_info["dictionary_format"]} not supported.')

if self.settings.preferences['running_mode'] != 'server':
cur_time_modified = os.path.getmtime(dictionary_info['dictionary_filename'])
if prev_time_modified and prev_time_modified < cur_time_modified:
self.settings.update_dictionary_modification_time(dictionary_info['dictionary_name'],
cur_time_modified)

def __init__(self, app: Flask) -> None:
app.extensions['dictionaries'] = self

Expand Down

0 comments on commit a9bd2b9

Please sign in to comment.