dsnopek / anki-sync-server

A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)
GNU Affero General Public License v3.0
741 stars 95 forks source link

Anki Droid request deleted files and fails with uploadChanges() #45

Closed Akendo closed 7 years ago

Akendo commented 8 years ago

I try to sync some collection with AnkiDroid, but there are some critical problems.

During the synchronization of the AnkiDroid (latest stable version 2.6 from F-Droid) the AnkDroid tries to download old images from the server, that I have remove via the Desktop Client. (running Tools>Check Media)

I create the files that were missing, but after this he's rasing following error message:

ERROR:root:CollectionThread[/home/akendo/src/anki-sync-server/collections/akendo/collection.anki2]: Unable to uploadChanges(*[], **{}): not enough arguments for format string
Traceback (most recent call last):
  File "/home/akendo/src/anki-sync-server/AnkiServer/threading.py", line 95, in _run
    ret = self.wrapper.execute(func, args, kw, return_queue)
  File "/home/akendo/src/anki-sync-server/AnkiServer/collection.py", line 58, in execute
    ret = func(*args, **kw)
  File "/home/akendo/src/anki-sync-server/AnkiServer/apps/sync_app.py", line 651, in run_func
    res = handler_method(**keyword_args)
  File "/home/akendo/src/anki-sync-server/AnkiServer/apps/sync_app.py", line 113, in uploadChanges
    processed_count = self._adopt_media_changes_from_zip(data)
  File "/home/akendo/src/anki-sync-server/AnkiServer/apps/sync_app.py", line 191, in _adopt_media_changes_from_zip
    self._remove_media_files(media_to_remove)
  File "/home/akendo/src/anki-sync-server/AnkiServer/apps/sync_app.py", line 236, in _remove_media_files
    "%s" % filename, str(err))
TypeError: not enough arguments for format string
----------------------------------------
Exception happened during processing of request from ('172.17.7.25', 44928)
Traceback (most recent call last):
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/paste/httpserver.py", line 1085, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/paste/httpserver.py", line 459, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib64/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/paste/httpserver.py", line 454, in handle_one_request
    self.wsgi_execute()
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/paste/httpserver.py", line 304, in wsgi_execute
    self.wsgi_start_response)
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/paste/translogger.py", line 69, in __call__
    return self.application(environ, replacement_start_response)
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/paste/urlmap.py", line 216, in __call__
    return app(environ, start_response)
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/home/akendo/.virtualenvs/anki-sync-server/lib/python2.7/site-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/home/akendo/src/anki-sync-server/AnkiServer/apps/sync_app.py", line 634, in __call__
    return self._execute_handler_method_in_thread(url, data, session)
  File "/home/akendo/src/anki-sync-server/AnkiServer/apps/sync_app.py", line 660, in _execute_handler_method_in_thread
    result = thread.execute(run_func)
  File "/home/akendo/src/anki-sync-server/AnkiServer/threading.py", line 76, in execute
    raise ret
TypeError: not enough arguments for format string
----------------------------------------
INFO:root:Monitor is closing collection on inactive CollectionThread[/home/akendo/src/anki-sync-server/collections/akendo/collection.anki2]
INFO:root:CollectionThread[/home/akendo/src/anki-sync-server/collections/akendo/collection.anki2]: Running _close(*[], **{})

I'm quite not sure who's causing this type of misbehavior. Any suggestion?

cdpm commented 7 years ago

There is an error in a format string in SyncMediaHandler._remove_media_files() when removing a file fails. #46 should fix it.

dsnopek commented 7 years ago

Merged #46 - @Akendo: please test with the latest version in 'master' when you have a chance and confirm that this fixes the issue for you. Thanks!

Akendo commented 7 years ago

I'm on it!

Akendo commented 7 years ago

Seems to work, i get some error that files are missing. But the android clients does not raise any error message. No trace in the server side.

I might have to clean up old images. But that's another issue.

Thank you very much!

dsnopek commented 7 years ago

Great! Thanks for testing :-)