Skip to content

Incompatible with arch-based clients #24

@AlexBocken

Description

@AlexBocken

Hi there!

I've noticed how the syncing does not appear to work with arch based clients. Here's the log of me trying to sync this way:

◆ src ❯❯❯ python -m ankisyncd
[2020-09-05 11:12:31,367]:INFO:ankisyncd:ankisyncd 049bb04 (https://github.com/tsudoko/anki-sync-server)
[2020-09-05 11:12:31,378]:INFO:ankisyncd:Loaded config from /root/anki-sync-server/src/ankisyncd.conf
[2020-09-05 11:12:31,379]:INFO:ankisyncd.users:Found auth_db_path in config, using SqliteUserManager for auth
[2020-09-05 11:12:31,380]:INFO:ankisyncd.sessions:Found session_db_path in config, using SqliteSessionManager for auth
[2020-09-05 11:12:31,382]:INFO:ankisyncd:Serving HTTP on 0.0.0.0 port 27702...
[2020-09-05 11:12:36,191]:INFO:ankisyncd.CollectionThread[alex]:Starting...
[2020-09-05 11:12:36,191]:INFO:ankisyncd.CollectionThread[alex]:Running meta(*[], **{'v': 10, 'cv': 'ankidesktop,2.1.26 (arch-linux-2.1.26-1),lin:arch:'})
[2020-09-05 11:12:36,202]:ERROR:ankisyncd.CollectionThread[alex]:Unable to meta(*[], **{'v': 10, 'cv': 'ankidesktop,2.1.26 (arch-linux-2.1.26-1),lin:arch:'}): invalid literal for int() with base 10:
'h-linux-2.1.26-1)'
Traceback (most recent call last):
  File "/root/anki-sync-server/src/ankisyncd/thread.py", line 98, in _run
    ret = self.wrapper.execute(func, args, kw, return_queue)
  File "/root/anki-sync-server/src/ankisyncd/collection.py", line 45, in execute
    ret = func(*args, **kw)
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 575, in run_func
    res = handler_method(**keyword_args)
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 89, in meta
    if self._old_client(cv):
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 71, in _old_client
    note[name] = int(vs[-1])
ValueError: invalid literal for int() with base 10: 'h-linux-2.1.26-1)'
Traceback (most recent call last):
  File "/usr/lib/python3.8/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/lib/python3.8/site-packages/webob/dec.py", line 129, in __call__
    resp = self.call_func(req, *args, **kw)
  File "/usr/lib/python3.8/site-packages/webob/dec.py", line 193, in call_func
    return self.func(req, *args, **kwargs)
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 519, in __call__
    result = self._execute_handler_method_in_thread(url, data, session)
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 584, in _execute_handler_method_in_thread
    result = thread.execute(run_func, kw=keyword_args)
  File "/root/anki-sync-server/src/ankisyncd/thread.py", line 79, in execute
    raise ret
  File "/root/anki-sync-server/src/ankisyncd/thread.py", line 98, in _run
    ret = self.wrapper.execute(func, args, kw, return_queue)
  File "/root/anki-sync-server/src/ankisyncd/collection.py", line 45, in execute
    ret = func(*args, **kw)
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 575, in run_func
    res = handler_method(**keyword_args)
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 89, in meta
    if self._old_client(cv):
  File "/root/anki-sync-server/src/ankisyncd/sync_app.py", line 71, in _old_client
    note[name] = int(vs[-1])
ValueError: invalid literal for int() with base 10: 'h-linux-2.1.26-1)'
[2020-09-05 11:12:36,208]:INFO:ankisyncd.http:127.0.0.1 "POST /sync/meta HTTP/1.0" 500 59
^C[2020-09-05 11:12:41,917]:INFO:ankisyncd:Exiting...

Looking into the mentioned file it seems because in the code it just checks whether the name includes "alpha", "beta" or "rc". Arch based clients do seem get wrongly included in that check:

anki-sync-server/src/ankisyncd/sync_app.py:

note = {"alpha": 0, "beta": 0, "rc": 0}
        client, version, platform = cv.split(',')

        for name in note.keys():
            if name in version:
                #if name in 'arch':
                #    break
                vs = version.split(name)
                version = vs[0]
                note[name] = int(vs[-1])

Commented out in that section you can see my "fix" which makes the program at least usable to me. Could maybe someone with better coding skills than me look into implementing an actual fix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions