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

Git import that involves a redirect (uses a non-canonical path) fails #206

Open
aplaice opened this issue Dec 29, 2023 · 0 comments
Open

Comments

@aplaice
Copy link
Collaborator

aplaice commented Dec 29, 2023

(Very minor, accidentally discovered while manually testing...)

If you try to import from a git repository via a non-canonical path (e.g. with different capitalisation — for instance https://github.com/Stvad/software_Engineering__git instead of https://github.com/Stvad/Software_Engineering__git), such that there is a redirect, then the import fails.

Details
Error: There is no /home/adam/test_crowdanki/addons21/1788670778/user_files/User 1/software_Engineering__git/software_Engineering__git.json file inside of the selected directory. While trying to import deck from directory /home/adam/test_crowdanki/addons21/1788670778/user_files/User 1/software_Engineering__git


Anki 23.12.1 (1a1d4d54)  (ao)
Python 3.9.15 Qt 6.6.1 PyQt 6.6.1
Platform: Linux-6.2.0-39-generic-x86_64-with-glibc2.35

Traceback (most recent call last):
  File "/home/adam/test_crowdanki/addons21/1788670778/anki/ui/action_vendor.py", line 36, in <lambda>
    lambda: GitImporter.on_git_import_action(self.window.col))
  File "/home/adam/test_crowdanki/addons21/1788670778/github/github_importer.py", line 28, in on_git_import_action
    GitImporter(collection).import_from_git()
  File "/home/adam/test_crowdanki/addons21/1788670778/github/github_importer.py", line 33, in import_from_git
    self.clone_repository_and_import(repo_url)
  File "/home/adam/test_crowdanki/addons21/1788670778/github/github_importer.py", line 48, in clone_repository_and_import
    AnkiJsonImporter.import_deck_from_path(self.collection, repo_local_path)
  File "/home/adam/test_crowdanki/addons21/1788670778/importer/anki_importer.py", line 101, in import_deck_from_path
    if importer.load_deck(directory_path):
  File "/home/adam/test_crowdanki/addons21/1788670778/importer/anki_importer.py", line 29, in load_deck
    deck_json = self.read_deck(self.get_deck_path(directory_path))
  File "/home/adam/test_crowdanki/addons21/1788670778/importer/anki_importer.py", line 76, in read_deck
    raise ValueError("There is no {} file inside of the selected directory".format(file_path))
ValueError: There is no /home/adam/test_crowdanki/addons21/1788670778/user_files/User 1/software_Engineering__git/software_Engineering__git.json file inside of the selected directory

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
CrowdAnki JSON exportimport Edit history Collaborate on deck creation ['1788670778', 2023-10-30T19:57, 'None', mod]

===IDs of active AnkiWeb add-ons===
1788670778

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

I believe that the issue is that we git clone to a path given by the canonical name (i.e. "redirected name"), but then try to import the deck.json from a path given by the final part of the user-provided (non-canonical) name.

Presumably we should either:

  1. clone to the final part of the user-provided (non-canonical) name
  2. get the name of the successful clone and use that.

2 is probably preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant