Fix long media sync times on AnkiDroid
Based on PR #44 by Johannes Schirm <https://github.com/Marth68>. The code is pretty much the same, but with usn used instead of mtime for determining which media files have changed since last sync. Relevant excerpt from #44: > The server was always sending metadata for all files in the > collection as a response to the mediaChanges operation. Because > AnkiDroid then calculates checksums for all these files (just to > notice that they actually haven't changed), it took larger > collections very long to sync after every media change. With this > fix, only the number of files indicated by usn - lastUsn (and > mtime) are considered for each sync. Fixes #26, closes #44.
This commit is contained in:
parent
10f47611bf
commit
e8f274ee84
@ -318,11 +318,11 @@ class SyncMediaHandler:
|
||||
|
||||
def mediaChanges(self, lastUsn):
|
||||
result = []
|
||||
usn = self.col.media.lastUsn()
|
||||
server_lastUsn = self.col.media.lastUsn()
|
||||
fname = csum = None
|
||||
|
||||
if lastUsn < usn or lastUsn == 0:
|
||||
for fname,usn,csum, in self.col.media.db.execute("select fname,usn,csum from media"):
|
||||
if lastUsn < server_lastUsn or lastUsn == 0:
|
||||
for fname,usn,csum, in self.col.media.db.execute("select fname,usn,csum from media order by usn desc limit ?", server_lastUsn - lastUsn):
|
||||
result.append([fname, usn, csum])
|
||||
|
||||
return {'data': result, 'err': ''}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user