Skip to content

Commit

Permalink
Merge pull request #167 from aplaice/new_backup_2.1.50
Browse files Browse the repository at this point in the history
Adapt to 2.1.50+ backup mechanism
  • Loading branch information
aplaice authored May 21, 2022
2 parents ad79b3f + d743f24 commit fcc0e29
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crowd_anki/anki/overrides/exporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_save_file(parent, title, dir_description, key, ext, fname=None):
directory = str(QFileDialog.getExistingDirectory(caption="Select Export Directory",
directory=fname))
if directory:
return os.path.join(directory, str(anki.utils.intTime()))
return os.path.join(directory, str(anki.utils.int_time()))
return None

return aqt.utils.getSaveFile_old(parent, title, dir_description, key, ext, fname)
Expand Down
4 changes: 1 addition & 3 deletions crowd_anki/importer/anki_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def load_deck(self, directory_path) -> bool:
return False

if aqt.mw:
aqt.mw.col.close(downgrade=False)
aqt.mw.backup()
aqt.mw.col.reopen(after_full_sync=False)
aqt.mw.create_backup_now()
try:
deck = deck_initializer.from_json(deck_json)
deck.save_to_collection(self.collection, import_config=import_config)
Expand Down
2 changes: 1 addition & 1 deletion crowd_anki/representation/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_media_file_list(self, data_from_models=True, include_children=True):
# TODO Remove compatibility shims for Anki 2.1.46 and
# lower.
join_fields = anki_object.joined_fields if hasattr(anki_object, 'joined_fields') else anki_object.joinedFields
for media_file in self.collection.media.filesInStr(anki_object.mid, join_fields()):
for media_file in self.collection.media.files_in_str(anki_object.mid, join_fields()):
media.add(media_file)

if include_children:
Expand Down
2 changes: 1 addition & 1 deletion crowd_anki/representation/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def save_to_collection(self, collection, deck, model_map_cache, import_config):

self.anki_object.__dict__.update(self.anki_object_dict)
self.anki_object.mid = note_model.anki_dict["id"]
self.anki_object.mod = anki.utils.intTime()
self.anki_object.mod = anki.utils.int_time()

if new_note:
collection.add_note(self.anki_object, deck.anki_dict["id"])
Expand Down

0 comments on commit fcc0e29

Please sign in to comment.