Skip to content

Commit

Permalink
Merge pull request #139 from aplaice/close_dulwich_repos
Browse files Browse the repository at this point in the history
Close all opened dulwich repo objects
  • Loading branch information
aplaice authored Nov 23, 2021
2 parents a7bb43a + fd0296f commit e253603
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
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()

0 comments on commit e253603

Please sign in to comment.