Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated anki-sync-server to work with the latest version of Anki #20

Merged
merged 38 commits into from
Sep 3, 2020

Conversation

kalehmann
Copy link

@kalehmann kalehmann commented Aug 28, 2020

This PR tackles the following issues: #13, #14, #16 and #19.

  • The embedded Anki submodule was removed, anki-sync-server now supports the current version of Anki installed by pip install anki.
  • To support newer versions of Anki, a Nginx-Proxy to "unchunk" requests is required before the anki-sync-server
  • An example addon for Anki versions >= 2.1.28 is provided in the Readme
  • The web media test was removed, because it depended on the MediaSyncer class, which no longer exists

I tested these changes with the latest master of AnkiDroid and Anki 2.1.28. I have found no issues while syncing between these two.

Required steps before merging

  • Patching all tests to work with the new code
  • Write Anki dependency to lock file

This commit applies the fix from
https://github.com/tsudoko/anki-sync-server/pull/60/files

However it using a shorter version by utilizing the params attribute of
the webob request. The params attribute combines the get and post params
This method was removed in
a2b7a3084131f747fb476cc8a24f96a00c654859
@AlexBocken
Copy link

  • To support newer versions of Anki, a Nginx-Proxy to "unchunk" requests is required before the anki-sync-server

If I try to run the example unchunker as given in the Readme using nginx, I'm not able to run the ankisyncd server at the same time via python -m ankisyncd as this Error: OSError: [Errno 98] Address already in use get's raised.

Which seems reasonable to me as an error. Of course this could be a result of my incompetence with nginx, I'm rather new to it. Does ankisyncd.conf need to modified to use a different port? But then the proxy_pass setting in the given example nginx setup does not make sense to me anymore.

Would it be possible to update the documentation to further clarify this area for an easier implementation? (I'm already quite grateful for the example nginx config at all). My guess is that other's who will try to to implement this workaround will have similar issues if they're not too familiar with nginx.

I apologize if this is the wrong place for a comment like this, but I didn't feel like it's appropriate to raise an issue on this project and the issues feature seems to be disabled on your personal fork.

@kalehmann kalehmann force-pushed the patch-issue-13 branch 2 times, most recently from c5075a9 to d3456a2 Compare August 31, 2020 14:55
@kalehmann
Copy link
Author

kalehmann commented Aug 31, 2020

HI @AlexBocken, thank you for your input.

I apologize if this is the wrong place for a comment like this, but I didn't feel like it's appropriate to raise an issue on this project and the issues feature seems to be disabled on your personal fork.

Your comment is suited perfectly fine here as it describes a problem introduced by this pull request 😄

During development I have used docker and both services (ankisyncd and Nginx) ran on different containers. Therefore they could both listen at same port (inside their respective containers). As you have already found out, this is not possible when both services run on your local machine.

I have updated the README file and further clarified how Nginx should be configured when both services run on the same machine.

@AlexBocken
Copy link

Thanks for the clarifications!

Copy link
Member

@VikashKothary VikashKothary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mate this is great work. It's all looks good to me. Thanks for all your hard work. A few quick changes and this PR should be ready to be merged.

.gitignore Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
src/ankisyncd/sync_app.py Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Contributor

@AntonOfTheWoods AntonOfTheWoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some code that looks like it is no longer needed. AFAICT, for example, there is no longer any particular use for the runHooks. The sync method is also, unless I'm mistaken, client-side code. As we now have to maintain this, it is very important not to have dead code that will just confuse future contributors. Can you give the file a clean?

Copy link
Contributor

@AntonOfTheWoods AntonOfTheWoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you deleting code you added in 59603b8 ? If so, can you combine the commits instead? If not, I'm lost, could you explain? :-)

@AntonOfTheWoods
Copy link
Contributor

Thanks again for the great work @kalehmann ! Apart from a couple of minor issues it looks great. I know it's sometimes hard and a little annoying but maybe next time maybe try and have several smaller PRs to avoid changing the same parts of the code in several commits of the PR.

@kalehmann
Copy link
Author

AFAICT, for example, there is no longer any particular use for the runHooks. The sync method is also, unless I'm mistaken, client-side code.

You were right, the runHook calls and the sync method served no purpose for us anymore.

As we now have to maintain this, it is very important not to have dead code that will just confuse future contributors. Can you give the file a clean?

I have removed any code related to these two points. But I still believe, that there is more unused code in this project. However I think that finding and removing these lines would better suite another PR.

@kalehmann
Copy link
Author

Are you deleting code you added in 59603b8 ? If so, can you combine the commits instead?

Yes, it seems like Anki desktop only accepts the downgraded database, therefore I reverted these changes. Anyways, I squashed these two commits

@kalehmann
Copy link
Author

I know it's sometimes hard and a little annoying but maybe next time maybe try and have several smaller PRs to avoid changing the same parts of the code in several commits of the PR.

Yeah I know 🤔 The problem is just, that when I started working on this PR I didn't even know how big it would get. I believe splitting it into smaller changes requires a profound evaluation of all necessary changes beforehand - which I was unable to do because I knew nothing about this project.

@AntonOfTheWoods
Copy link
Contributor

Yes, it seems like Anki desktop only accepts the downgraded database, therefore I reverted these changes. Anyways, I squashed these two commits

That's interesting, I didn't follow that up for djankiserv, it "Just Worked", and I didn't really know why :-). I definitely think that they will fully migrate to the new structure soon though, so that is definitely a TODO to test properly.

@AntonOfTheWoods
Copy link
Contributor

I have removed any code related to these two points. But I still believe, that there is more unused code in this project. However I think that finding and removing these lines would better suite another PR.

Oh, how many times I would have liked to have got away with that at my last company... :-). The way I am managing this for importing upstream code to djankiserv is to bring in a module then write tests to get the code to do useful stuff. Then run coverage and anything that hasn't been run gets the chop. It is pretty violent and misses cases but we can always go back and get code if it really was necessary. Let's definitely plan for something like this!

Copy link
Contributor

@AntonOfTheWoods AntonOfTheWoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. There is a lot of cleanup to be done but there was before so let's get this merged and move forward from there.

@AntonOfTheWoods AntonOfTheWoods merged commit 049bb04 into ankicommunity:develop Sep 3, 2020
This was referenced Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants