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

Close all opened dulwich repo objects #139

Merged
merged 4 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crowd_anki/github/github_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def clone_repository_and_import(self, repo_url):
repo_url = repo_url.strip()
try:
repo_local_path = self.get_repo_local_path(repo_url)
porcelain.pull(porcelain.open_repo(str(repo_local_path)), repo_url)
porcelain.pull(str(repo_local_path), repo_url)
except ValueError:
return self.notifier.error("URL incorrect", f"URL could not be parsed \"{repo_url}\"")
except NotGitRepository:
Expand All @@ -49,9 +49,9 @@ def clone_repository_and_import(self, repo_url):

def clone_repository(self, repo_url, repo_path):
repo_path.mkdir(parents=True, exist_ok=True)
porcelain.clone(repo_url, target=str(repo_path), bare=False, checkout=True, errstream=porcelain.NoneStream(),
outstream=porcelain.NoneStream())
repo_object = porcelain.clone(repo_url, target=str(repo_path), bare=False, checkout=True, errstream=porcelain.NoneStream())
repo_object.close()

def get_repo_local_path(self, repo_url):
repo_name = get_repository_name(repo_url)
return ConfigSettings.get_instance().full_snapshot_path.joinpath(repo_name)
return ConfigSettings.get_instance().full_snapshot_path.joinpath(repo_name)
1 change: 1 addition & 0 deletions crowd_anki/history/anki_deck_archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ def archive(self, _: Iterable = tuple(), reason=None):
repo = self.repo_provider(deck_path)
repo.stage_all()
repo.commit(reason)
repo.close()
3 changes: 3 additions & 0 deletions crowd_anki/history/dulwich_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ def there_are_staged_changes(self):

def status(self) -> GitStatus:
return self.git.status(self.dulwich_repo)

def close(self):
self.dulwich_repo.close()