Code Monkey home page Code Monkey logo

ankicommunity-sync-server's People

Contributors

agrueneberg avatar alexbocken avatar antonofthewoods avatar cashpw avatar cecini avatar cycatz avatar dobefore avatar dreamflasher avatar dsnopek avatar gzz2000 avatar izidormatusov avatar jdoe9910 avatar kalehmann avatar luckyturtledev avatar marzzzello avatar ohdearaugustin avatar ospalh avatar reivilibre avatar samyak-jain avatar tomromeo avatar tsudoko avatar upsuper avatar valuex avatar vikashkothary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ankicommunity-sync-server's Issues

Addon does not set the sync-server url in Anki versions > 2.1.26

As of Anki version 2.1.28, the server address is not affected by the addon anymore.

What did I do?

I installed Anki 2.1.28 and created an addon with the following content:

import anki.sync, anki.hooks, aqt

addr = "http://127.0.0.1:27701/" # put your server address here
anki.sync.SYNC_BASE = "%s" + addr
def resetHostNum():
    aqt.mw.pm.profile['hostNum'] = None
anki.hooks.addHook("profileLoaded", resetHostNum)

Then I started Anki and hit the Sync button.

What did I expect to happen?

I expected Anki to make a request to the url specified in the addon.

What did happen instead?

Anki made a request to https://sync.ankiweb.net/msync/ instead.

Further information

The urls used for synchronizaton are hardcoded to https://sync.ankiweb.net since the commits 0e5b7da62aa0fd3726ca958f1cdae265d2dc0d91 and 529e89f48e747904ffd9c8ebac09739fb410bcaf.
Therefore they cannot be easily changed by the addon anymore.

Incompatibility with ARM-based OS

Due to the anki PyPi module. The Rust aspects have not been compiled for the ARM architecture. This limits the use of this tool with devices such as Raspberry Pis. This will change.

Media sync error with anki 2.1.35

After updating to anki 2.1.35, media sync fails with this message error :

A network error occurred.

Error details: ⁨Please force a full sync in the Preferences screen to bring your devices into sync. 
Then, please use the Check Database feature, and sync to your other devices. 
If problems persist, please post on the support forum.

error decoding response body: invalid type: null, expected a string at line 1 column 389⁩

I don't see an error via anki-sync-server (I truncated a few lines for readability):

INFO:ankisyncd.CollectionThread[anhtuann]:Running begin(*[], **{'skey': 'd60f0e0c'})
INFO:ankisyncd.http:127.0.0.1 "GET /msync/begin?k=d3032a86ba830b783577ed5d4f64b37a&v=anki%2C2.1.>
INFO:ankisyncd.CollectionThread[anhtuann]:Running meta(*[], **{'v': 10, 'cv': 'anki,2.1.35 (84dc>
INFO:ankisyncd.http:127.0.0.1 "POST /sync/meta HTTP/1.0" 200 149
INFO:ankisyncd.CollectionThread[anhtuann]:Running mediaChanges(*[], **{'lastUsn': 31480})
INFO:ankisyncd.http:127.0.0.1 "POST /msync/mediaChanges HTTP/1.0" 200 1310
INFO:ankisyncd.CollectionThread[anhtuann]:Running start(*[], **{'minUsn': 632, 'offset': -60, 'l>
INFO:ankisyncd.http:127.0.0.1 "POST /sync/start HTTP/1.0" 200 39
INFO:ankisyncd.CollectionThread[anhtuann]:Running applyChanges(*[], **{'changes': {'models': [],>
INFO:ankisyncd.http:127.0.0.1 "POST /sync/applyChanges HTTP/1.0" 200 45
INFO:ankisyncd.CollectionThread[anhtuann]:Running chunk(*[], **{})
INFO:ankisyncd.http:127.0.0.1 "POST /sync/chunk HTTP/1.0" 200 54
INFO:ankisyncd.CollectionThread[anhtuann]:Running applyChunk(*[], **{'chunk': {'done': True}})
INFO:ankisyncd.http:127.0.0.1 "POST /sync/applyChunk HTTP/1.0" 200 4
INFO:ankisyncd.CollectionThread[anhtuann]:Running sanityCheck2(*[], **{'client': [[0, 0, 0], 978>
INFO:ankisyncd.http:127.0.0.1 "POST /sync/sanityCheck2 HTTP/1.0" 200 16
INFO:ankisyncd.CollectionThread[anhtuann]:Running finish(*[], **{})
INFO:ankisyncd.http:127.0.0.1 "POST /sync/finish HTTP/1.0" 200 13

Update dependencies

  • Remove if not needed any more
  • Move to dev if not needed for running the actual project
  • Update documentation

I have no way to update the anki version. The synchronization server reported an error

After anki 1.28, login display user and password error. I update the previous code according to the updated anki sync server to work with the latest version of anki ා 20, but the server still cannot be used and an error is reported

File "/usr/lib/python3.6/ runpy.py ",line 193 in _ run_ module_ As_ main

"Wei" main__ ",mod_ spec)

File "/home/anki/anki/anki-sync-server/ankisyncd/__ main__ .py" line 8, in import ankisyncd.sync_ App

File "/home/anki/anki/anki-sync-server/ankisyncd/sync_ app.py " line37, in import anki.db

ModuleNotFoundError: No module named 'anki'

Please tell me how to deal with this problem. There are many documents updated in question 20. Do I need to update these documents? Thank you for your guidance

Error "missing field `mod` at line 1 column 99" when initiating sync from client

Observed behavior

After initiating sync in the Anki client, I see the following:

A network error occurred.
Error details: ⁨error decoding response body: missing field `mod` at line 1 column 99⁩

It also tells me my ID and password are incorrect.

In the server I see the following after making the request:

...startup messages...
anki-sync-server    | [2020-11-28 19:20:05,431]:INFO:ankisyncd.http:172.30.0.1 "GET /msync/begin?k=c63b69986acdcaff9ad11f877163d90c&v=anki%2C2.1.35+%2884dcaa86%29%2Clin%3Aarch%3Arolling HTTP/1.0" 403 157
anki-sync-server    | [2020-11-28 19:20:05,477]:INFO:ankisyncd.CollectionThread[ndwar]:Starting...
anki-sync-server    | [2020-11-28 19:20:05,478]:INFO:ankisyncd.CollectionThread[ndwar]:Running meta(*[], **{'v': 10, 'cv': 'anki,2.1.35 (84dcaa86),lin:arch:rolling'})
anki-sync-server    | [2020-11-28 19:20:05,488]:INFO:ankisyncd.http:172.30.0.1 "POST /sync/meta HTTP/1.0" 200 99

Server information

Anki sync server was set up using docker-compose:

version: "3"

services:
  anki-sync-server:
    image: kuklinistvan/anki-sync-server:latest
    container_name: anki-sync-server

    restart: always
    ports:
    - "9005:27701"
    volumes:
    - /mnt/data/docker-vols/anki-sync-server:/app/data

And I have it reverse-proxied using nginx (minimal config):

#user html;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    types_hash_max_size 4096;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log main;
    error_log /var/log/nginx/error.log notice;
    
    sendfile on;
    keepalive_timeout 65;
    gzip  on;

    server {
	listen 80;
        return 404;
    }

    server {
        listen 80;
        server_name ankiurl;
	location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header HOST $host;
            proxy_set_header Referer $http_referer;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host:$server_port;
            include conf.d/proxy-headers.conf;
            include conf.d/proxy-x-headers.conf;
	    proxy_http_version 1.0;
            proxy_pass http://127.0.0.1:9005;
	}
    }
}

User was created without error:

/app/anki-sync-server # ./ankisyncctl.py adduser myuser
Enter password for myuser 

Client information

Debug output from Help > About

    
    Anki 2.1.35 (84dcaa86) Python 3.8.6 Qt 5.15.2 PyQt 5.15.2
    Platform: Linux
    Flags: frz=False ao=True sv=1
    Add-ons, last update check: 2020-11-28 10:23:13
    
    
    ===Add-ons (active)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    '' ['ankisyncd', 0, 'None', '']
    
    ===IDs of active AnkiWeb add-ons===
    
    
    ===Add-ons (inactive)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    

Contents of the ankisyncd addon:

import os

addr = "http://myurl/"
os.environ["SYNC_ENDPOINT"] = addr + "sync/"
os.environ["SYNC_ENDPOINT_MEDIA"] = addr + "msync/"

v2 scheduler support

There was a pull request that never got merged with Tsudoko's repo concerning the v2 scheduler.

tsudoko/anki-sync-server#53

I applied this to my own copy and it has been working for the last few months without issue. Just leaving this here if anyone else is also using the v2 scheduler.

anki desktop 2.1.41-42 Unable to start(*[], **{'minUsn': 0, 'lnewer': True, 'graves': None}): 'NoneType' object is not subscriptable

When I was testing the version of anki2.1.41, I encountered the following problem: "nonetype" object is not subsertable.
how i can fix it ?

this is the error ,'graves' show None
Running start(*[], **{'minUsn': 0, 'lnewer': True, 'graves': None})

Unable to start(*[], **{'minUsn': 0, 'lnewer': True, 'graves': None}): 'NoneType' object is not subscriptable

the right 'garves' like this ?
Running begin(*[], **{'skey': '424f9c42'})

Forced synchronization can be executed. If you just click synchronization, an error will be reported. It is found that the last parameter graves in the parameter package after begin is set to none. Under normal circumstances,I’m not sure if this problem is caused by the new version enabling V2,"The offset para is passed by client V2 " Please master advice, how to deal with. be deeply grateful!

Traceback (most recent call last):
File "/anki-sync-server/src/ankisyncd/thread.py", line 98, in _run
ret = self.wrapper.execute(func, args, kw, return_queue)
File "/anki-sync-server/src/ankisyncd/collection.py", line 45, in execute
ret = func(*args, **kw)
File "/anki-sync-server/src/ankisyncd/sync_app.py", line 579, in run_func
res = handler_method(**keyword_args)
File "/anki-sync-server/src/ankisyncd/sync_app.py", line 124, in start
self.remove(graves)
File "/anki-sync-server/src/ankisyncd/sync.py", line 189, in remove
self.col.remove_cards_and_orphaned_notes(graves['cards'])
TypeError: 'NoneType' object is not subscriptable
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/local/lib/python3.8/dist-packages/webob/dec.py", line 129, in call
resp = self.call_func(req, *args, **kw)
File "/usr/local/lib/python3.8/dist-packages/webob/dec.py", line 193, in call_func
return self.func(req, *args, **kwargs)
File "/anki-sync-server/src/ankisyncd/sync_app.py", line 523, in call
result = self._execute_handler_method_in_thread(url, data, session)
File "/anki-sync-server/src/ankisyncd/sync_app.py", line 588, in _execute_handler_method_in_thread
result = thread.execute(run_func, kw=keyword_args)
File "/anki-sync-server/src/ankisyncd/thread.py", line 79, in execute
raise ret
File "/anki-sync-server/src/ankisyncd/thread.py", line 98, in _run
ret = self.wrapper.execute(func, args, kw, return_queue)
File "/anki-sync-server/src/ankisyncd/collection.py", line 45, in execute
ret = func(*args, **kw)
File "/anki-sync-server/src/ankisyncd/sync_app.py", line 579, in run_func
res = handler_method(**keyword_args)
File "/anki-sync-server/src/ankisyncd/sync_app.py", line 124, in start
self.remove(graves)
File "/anki-sync-server/src/ankisyncd/sync.py", line 189, in remove
self.col.remove_cards_and_orphaned_notes(graves['cards'])
TypeError: 'NoneType' object is not subscriptable

2.1.40_sync_error_no_attribute_basicCheck

Anki desktop:2.1.40
OS:Win10
anki:2.1.40
once installed,I started anki , input account and hit sync.

 File "C:\Users\Admin\Desktop\ANKI-S~1\ANKI_S~1.36\ankisyncd\sync_app.py", line 588, in _execute_handler_method_in_thread
    result = thread.execute(run_func, kw=keyword_args)
  File "C:\Users\Admin\Desktop\ANKI-S~1\ANKI_S~1.36\ankisyncd\thread.py", line 79, in execute
    raise ret
  File "C:\Users\Admin\Desktop\ANKI-S~1\ANKI_S~1.36\ankisyncd\thread.py", line 98, in _run
    ret = self.wrapper.execute(func, args, kw, return_queue)
  File "C:\Users\Admin\Desktop\ANKI-S~1\ANKI_S~1.36\ankisyncd\collection.py", line 45, in execute
    ret = func(*args, **kw)
  File "C:\Users\Admin\Desktop\ANKI-S~1\ANKI_S~1.36\ankisyncd\sync_app.py", line 579, in run_func
    res = handler_method(**keyword_args)
  File "C:\Users\Admin\Desktop\ANKI-S~1\ANKI_S~1.36\ankisyncd\sync_app.py", line 138, in sanityCheck2
    server = self.sanityCheck(full)
  File "C:\Users\Admin\Desktop\ANKI-S~1\ANKI_S~1.36\ankisyncd\sync.py", line 77, in sanityCheck
    if not self.col.basicCheck():
AttributeError: 'Collection' object has no attribute 'basicCheck'
[2021-02-11 21:05:05,624]:INFO:ankisyncd.http:127.0.0.1 "POST /sync/sanityCheck2 HTTP/1.0" 500 59
[2021-02-11 21:05:05,629]:INFO:ankisyncd.http:127.0.0.1 "POST /sync/abort HTTP/1.0" 404 154

Weird change in UI of AnkiDesktop after settiing up sync

Not sure why this is happening but I get a very weird change in the UI of the desktop app of Anki when I add the addon with the __init__.py as recommended in the documentation. The syncing works fine.

As soon as I add the addon, this is how the UI starts looking like:
image

Could this be a bug in Anki itself? Would love to know if anyone else is also facing this issue.

Anki Version: anki 2.1.35-3
Platform: Linux (5.10.7-arch1-1)

同步失败: Traceback (most recent call last): File "aqt\sync.py", line 382, in _sync

同步失败:
Traceback (most recent call last):
File "aqt\sync.py", line 382, in _sync
File "aqt\sync.py", line 362, in abortingSync
File "anki\sync.py", line 42, in sync
File "anki\sync.py", line 594, in meta
File "json_init
.py", line 354, in loads
File "json\decoder.py", line 339, in decode
File "json\decoder.py", line 357, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Rust vs Python

This sync server is written in Python. Anki is a combination of Python and Rust.

The current plan is to keep this project entirely Python. If this would to change, it should be documented in this issue.

Your client is using unsupported sync protocol (10, supported version: 9) with latest version of Anki

How to reproduce ?

  • First I set up the latest master of the anki-sync-server
  • Then I go to apps.ankiweb.net and download the latest stable release (2.1.22).
  • After that I follow the instructions in the Readme to setup my sync server in Anki.
  • Now I hit synchronize

Expected behavior

Everything synchronizes just fine

Actual behavior

I get a dialog with the message

Your client is using unsupported sync protocol (10, supported version: 9)

Additional information

The message is issued in sync_app.py#L90

adding subdeck leads to sanity check failed on 2.1.36

I would like someone help me test whether my modified server code is right by taking the following actions:
@cecini sorry to bother you ,but need your help

  • create deck -> test::tt On desktop Anki 2.1.36

  • Then hit sync On Desktop

  • check if the check database function window will pop

It synced normally even though there was a subdeck before.However,today,I create a subdeck On desktop,Then sanity check failed on server output.

[2020-11-18 11:52:35,602]:INFO:ankisyncd.CollectionThread[puyuan]:Running sanityCheck2(*[], **{'client': [[0, 0, 0], 55558, 38730, 1035, 21, 17, 28, 2], 'full': True})
invalid current deck
[2020-11-18 11:52:35,715]:INFO:ankisyncd:sanity check failed with server: [[0, 0, 0], 55558, 38730, 1035, 21, 17, 27, 2] client: [[0, 0, 0], 55558, 38730, 1035, 21, 17, 28, 2] 


But after a while ,It back to normal(I guess the function automatically sync periodically works)
And after deleting the created subdeck,It returns back to normal too
Anki 2.1.36
anki mod 2.1.36

CI

I'm thinking GitLab CI. It involves creating a read-only clone in GitLab such that more people can find this project.

Heroku One-Click Deply

  • For non-technical users. Completely for free, self-hosted anki server.
  • Heroku Postgres will allow persistence.

api, or adding decks

Would it be a good idea to add an api or a cli for adding decks to this server? It would solve a huge problem for many people that don't want to use ankiconnect.

There are currently (at least that I could find), no way of adding decks without the anki ui. Being ankiweb or this server.

Goal is to automatically scan a bunch of markdown files and add from them, but without any ui.

Or is an api/cli for adding decks in this server impossible for some reasons? Technical or legally?

Syncing fails when depending on which deck is selected, works after changing selection

This one's a bit tricky, but here's what I think will reproduce it, using Anki 2.1.33:

  1. Delete your collection from the anki-sync-server folder to force a full sync
  2. Create a deck with no cards, don't change the deck focus
  3. Try to sync, Anki will prompt you to do a full sync
  4. Select upload

The following dialogue box will appear:

Anki_297

The server output is as follows:

[2020-09-23 18:20:50,888]:INFO:ankisyncd.CollectionThread[gene]:Running applyChanges(*[], **{'changes': {'models': [], 'decks': [[{'id': 1600903045930, 'mod': 1600903045, 'name': 'afaaafa', 'usn': 12154, 'lrnToday': [0, 0], 'revToday': [0, 0], 'newToday': [0, 0], 'timeToday': [0, 0], 'collapsed': False, 'browserCollapsed': False, 'desc': '', 'dyn': 0, 'conf': 1, 'extendNew': 0, 'extendRev': 0}], []], 'tags': []}})
[2020-09-23 18:20:50,901]:INFO:ankisyncd.http:xx.xxx.xx.xx "POST /sync/applyChanges HTTP/1.0" 200 330
[2020-09-23 18:20:51,028]:INFO:ankisyncd.CollectionThread[gene]:Running chunk(*[], **{})
[2020-09-23 18:20:51,033]:INFO:ankisyncd.http:xx.xxx.xx.xx "POST /sync/chunk HTTP/1.0" 200 54
[2020-09-23 18:20:51,158]:INFO:ankisyncd.CollectionThread[gene]:Running applyChunk(*[], **{'chunk': {'done': True}})
[2020-09-23 18:20:51,158]:INFO:ankisyncd.http:xx.xxx.xx.xx "POST /sync/applyChunk HTTP/1.0" 200 4
[2020-09-23 18:20:51,288]:INFO:ankisyncd.CollectionThread[gene]:Running sanityCheck2(*[], **{'client': [[0, 0, 0], 53808, 38512, 873759, 0, 17, 489, 18], 'full': True})
[2020-09-23 18:20:51,377]:INFO:ankisyncd:sanity check failed with server: [[0, 0, 3], 53808, 38512, 873759, 0, 17, 489, 18] client: [[0, 0, 0], 53808, 38512, 873759, 0, 17, 489, 18]

Partial remedy
When looking at the output, this reminded me of an old bug in AnkiDroid where the sync would fail if you selected a deck with too many cards. This time, I selected one of the bigger decks in my selection and after that I was able to sync without any issues.

cannot found Anki module

Following the procedures, I got:

(ankiweb) D:\Soft\Language\Anki\anki-sync-server\src>python -m ankisyncd
Traceback (most recent call last):
File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd_main
.py", line 8, in
import ankisyncd.sync_app
File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd\sync_app.py", line 37, in
import anki.db
ModuleNotFoundError: No module named 'anki'

So I googled and found dsnopek/anki-sync-server#40
There is a anki-bundled link in
https://github.com/dsnopek/anki-sync-server
Copying the downloaded anki folder to D:\Miniconda3\envs\ankiweb\Lib\site-packages
and rerun shows
Exception: Anki should be run with Python 2

So I download https://github.com/ankicommunity/anki-core/tree/master/anki and copy to D:\Miniconda3\envs\ankiweb\Lib\site-packages
Now the error is as follows:
(ankiweb) D:\Soft\Language\Anki\anki-sync-server\src>python -m ankisyncd
Traceback (most recent call last):
File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "d:\Miniconda3\envs\ankiweb\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd_main
.py", line 8, in
import ankisyncd.sync_app
File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd\sync_app.py", line 41, in
from ankisyncd.full_sync import get_full_sync_manager
File "D:\Soft\Language\Anki\anki-sync-server\src\ankisyncd\full_sync.py", line 11, in
from anki.collection import Collection
ImportError: cannot import name 'Collection' from 'anki.collection' (d:\Miniconda3\envs\ankiweb\lib\site-packages\anki\collection.py)

Please help, and Thanks!

Anki Win desktop 2.1.35 sync fail:please use the check database function,then sync again

Hi,there.
reproduce:
1.when I add a user on server and input it on PC Anki,first hit sync button,everything was Ok.Then I tried to add card with plain text or pictures(media) and synced,the following dialog popped out.
Snipaste_2020-10-03_18-43-58
I guess It cannot sync after operations of add/deleteing cards/decks and learning trace.

2.Then I go to tools-->preferences-->scheduling,select Anki 2.1 scheduler checkbox and closes.And I hit sync button,It prompts me to select upload and download .Then I hit download from ankiweb,It seems that works and the effect is equivalent to upload.Yet
upload button will show the check database dialog.

3.I wait for several minutes until logs like collection thread running close was printed on server window,I hit sync button again,the tiring check database dialog pop out once more.I must select Anki 2.1 scheduler in the preferences ,If I want to use it to sync.
And 2.1.33 is the same
above all, It works repeating this operation(I go to tools-->preferences-->scheduling ,select Anki 2.1 scheduler checkbox and closes and download (not upload) in order to add/delete or change learing process)

org.JSONException: a JSONObject text must begin with '{' at character 1 of Anki Sync Server

Hello,

First of all, thanks for your efforts in modernizing this package. I was prepared to spend a lot of time trying to learn the library and you have helped tremendously. I have gotten my server to work with Anki desktop through a https reverse proxy.

However, I'm having trouble with AnkiDroid. I am using version 2.13.3. Namely, this instruction in the README:

Use the same base url for both the Sync url and the Media sync url. Do not append /sync and /msync as the default setup does.

I have set up my fields as follows:

Sync url: https://myurl.com/

Media sync url: https://myurl.com/

However, when doing so, I get the following error upon media sync:

Screenshot_20200923-170248_AnkiDroid

The cards sync, so I am connecting to the server. However the media sync is where it fails.

A second observation is that despite the instructions telling me not to append my media sync url with 'mysnc', when I do that:

Media sync url: https://myurl.com/msync

It actually syncs. However it took 20 minutes to do so whereas with Tsudoko's version it used to take a second or two. I suspect it's crawling through my entire media folder of 47,000 files. See:

tsudoko/anki-sync-server#26

Then again, that was fixed here:

e8f274e

I tried adding some media again and then it took just a second. So maybe this problem just happens after version upgrades or when setting up a new server or something like that. But I'm still appending 'msync' to my media sync url, so I'm wondering if that is indeed not the right thing to do.

Thanks!

Sync crashes after deck deletion

Reproduction steps:

  1. Delete a deck
  2. Try to sync

I'm using Anki desktop 2.1.33. Upon sync, the dialogue box pops up:

Anki_296

Here's the traceback from the server:

Traceback (most recent call last):
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/thread.py", line 98, in _run
    ret = self.wrapper.execute(func, args, kw, return_queue)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/collection.py", line 45, in execute
    ret = func(*args, **kw)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync_app.py", line 574, in run_func
    res = handler_method(**keyword_args)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync_app.py", line 126, in applyGraves
    self.remove(chunk)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync.py", line 197, in remove
    self.col.decks.rem(oid, childrenToo=False)
  File "/home/ubuntu/lib/python3.8/site-packages/anki/decks.py", line 125, in rem
    assert cardsToo and childrenToo
AssertionError
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 "/home/ubuntu/lib/python3.8/site-packages/webob/dec.py", line 129, in __call__
    resp = self.call_func(req, *args, **kw)
  File "/home/ubuntu/lib/python3.8/site-packages/webob/dec.py", line 193, in call_func
    return self.func(req, *args, **kwargs)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync_app.py", line 518, in __call__
    result = self._execute_handler_method_in_thread(url, data, session)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync_app.py", line 583, in _execute_handler_method_in_thread
    result = thread.execute(run_func, kw=keyword_args)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/thread.py", line 79, in execute
    raise ret
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/thread.py", line 98, in _run
    ret = self.wrapper.execute(func, args, kw, return_queue)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/collection.py", line 45, in execute
    ret = func(*args, **kw)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync_app.py", line 574, in run_func
    res = handler_method(**keyword_args)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync_app.py", line 126, in applyGraves
    self.remove(chunk)
  File "/home/ubuntu/anki-sync-server/src/ankisyncd/sync.py", line 197, in remove
    self.col.decks.rem(oid, childrenToo=False)
  File "/home/ubuntu/lib/python3.8/site-packages/anki/decks.py", line 125, in rem
    assert cardsToo and childrenToo
AssertionError

Remove anki submodule dependency

There are a lot of changes. Currently very theoretical.

The anki submodule was needed because at the time of creating this project, there was no way of installing the client. This has not been the case for some time now. It would be a lot easier to just install the anki package from pip.

Potential Action List

  1. Find earliest version of anki deployed to PyPi
  2. Calculate difference between current submodule and anki package.
  3. Patch the difference

Alternative Action

  1. Create a repo for the submodule commit.
  2. Pip install repo
  3. Update repo commit by commit and see where it breaks

Why the anki desktop use HTTP 1.0?

Is there anyhone point where the code use the http1.0 version to req/response http req on anki desktop?

Just confirmation that ankiandroid /anki desktop always send http 1.0 req to sync server.
We should upgrade to http 1.1?

Medias don't sync with anki 2.1.26

Hello, I followed the instructions on the README.md and everything works fine except medias. There is no sync error on anki 2.1.26 but when I open the media log, I see this :

Wed Dec  2 21:19:34 2020: Media sync starting...
Wed Dec  2 21:19:34 2020: Please check your internet connection.

Error details: ⁨error sending request for url (): error trying to connect: dns error: 
failed to lookup address information: Name or service not known⁩

As previously stated, the cards are synced, only the medias are missing.

Here is my nginx reverse proxy :

server {
        server_name <url>;
                location / {
                proxy_http_version 1.0;
                proxy_pass http://localhost:27701/;
            }
    client_max_body_size 10M;

    listen 443 ssl; # managed by Certbot
    <ssl certificate via Certbot>
}

Edit : The problem seems to occur only with the desktop version (2.1.26), the media sync works with ankidroid (14.1)

Suggestion: Docker images that track this repo

Right now, the instructions ask us to use the following repo: https://github.com/ankicommunity/docker-anki-sync-server to deploy this server using Docker.

IMHO, I think the following

  • This is the wrong approach to take. Making a docker image is fairly straightforward. There is no reason this has to be in a seperate repository
  • The docker repo linked doesn't even track this repo despite the fact that this is the most actively maintained version of the server. The last commit for this repo was 4 days ago whereas for tsudoku's version is almost a year ago.
  • Because of this, the official docker image does not contain critical fixes needed for the application to function in many use cases. For example, since I use Arch Linux, any version of the server which does not contain a fix like #57 will be completely broken.

I think the best approach here should be to include a github action so that the latest tag of the official docker image tracks the master of this repo.

upload to ankiweb, Or modify the card attributes,Error when uploading data

In the anki desktop version, select in preferences to force one-way changes at the next synchronization. Then close anki, which prompts whether to upload or download. If you choose to upload, an error will be reported. You need to enter a user name and password,

error code :"POST /sync/upload HTTP/1.1 " 403 157
ankisyncd.ThreadingColletionMnagaer:Monoitor is closing collection on inctive CollectionThread

anki desktop 2.1.35

which will appear repeatedly. Please help me , how can i fix this problem?Thank you very much!

Move on from the WSGI environment to something that supports at least HTTP 1.1

Anki desktop tries to use a persistent HTTP connection with chunked transfer encoding.
As this is not supported by webob, newer versions of Anki require a reverse proxy that "unchunks" the requests, e.g.

server {
    listen      27701;
    server_name default;

    location / {
        proxy_http_version 1.0;
        proxy_pass         http://ankisyncd:27701/;
    }
}

This introduces another service that needs to run on the host next to the anki sync server. Therefore I suggest a switch to Twisted.

Incompatible with arch-based clients

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.