Skip to content

Commit

Permalink
Merge pull request #214 from aplaice/force_media_sync_on_import
Browse files Browse the repository at this point in the history
Force syncing of media after import
  • Loading branch information
aplaice authored Sep 15, 2024
2 parents db2fdf2 + 8da2c7a commit a750d7b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crowd_anki/importer/anki_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def import_media(self, directory_path):
full_filename = os.path.join(unicode_media_directory, filename)
if os.path.isfile(full_filename):
shutil.copy(full_filename, self.collection.media.dir())
# Set media dir mtime to force sync of media. Otherwise,
# if no media files are added or removed, Anki will not
# sync media changes. See the Anki source:
# https://github.com/ankitects/anki/blob/b7cb0c0d0081202586fd2d88541db962819736b3/rslib/src/sync/media/database/client/changetracker.rs#L59
os.utime(self.collection.media.dir())
else:
print("Warning: no media directory exists.")

Expand Down

0 comments on commit a750d7b

Please sign in to comment.