Store media usn per-file

Since anki.media.MediaManager does not store per-file usn (as it's
not really needed for anything in the client), this requires us to
drop it and implement a custom media manager.
This commit is contained in:
flan
2019-12-29 23:22:21 +01:00
parent ac1920d078
commit 10f47611bf
5 changed files with 122 additions and 64 deletions

View File

@@ -1,6 +1,8 @@
import anki
import anki.storage
import ankisyncd.media
import os, errno
import logging
@@ -63,7 +65,13 @@ class CollectionWrapper:
return col
def _get_collection(self):
return anki.storage.Collection(self.path)
col = anki.storage.Collection(self.path)
# Ugly hack, replace default media manager with our custom one
col.media.close()
col.media = ankisyncd.media.ServerMediaManager(col)
return col
def open(self):
"""Open the collection, or create it if it doesn't exist."""