Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Upcoming version

- Bugfix: Check the existence of a mirror while holding the mirror lock to no longer delete a mirror that was
created by a concurrent gitcache process.
- Bugfix: Fetch the LFS objects of a `git checkout` of a tag or a commit as well. Previously, only a checkout of a
branch triggered an LFS fetch of the mirror and the LFS objects of a tag or commit were downloaded by the git-lfs
filters of the checkout itself.
Expand Down
9 changes: 3 additions & 6 deletions src/git_cache/git_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,9 @@ def update(self, ref=None, force=False):
Return:
Returns True if the mirror was updated or False if the request timed out.
"""
mirror_exists = self.database.get(self.path) is not None
try:
with Locker(f"Mirror {self.path}", self.lockfile, self.config):
if not mirror_exists:
if self.database.get(self.path) is None:
rmtree(self.path, ignore_errors=True)
if self._clone(ref):
record_cache("miss_create", self.path)
Expand Down Expand Up @@ -202,10 +201,9 @@ def ensure_exists(self, ref=None) -> bool:
Return:
Returns True if the mirror exists now or False if the request timed out.
"""
mirror_exists = self.database.get(self.path) is not None
try:
with Locker(f"Mirror {self.path}", self.lockfile, self.config):
if not mirror_exists:
if self.database.get(self.path) is None:
rmtree(self.path, ignore_errors=True)
if self._clone(ref):
record_cache("miss_create", self.path)
Expand All @@ -227,10 +225,9 @@ def fetch(self, command_args: List[str]) -> bool:
Return:
Returns True if the command was successfull, otherwise False.
"""
mirror_exists = self.database.get(self.path) is not None
try:
with Locker(f"Mirror {self.path}", self.lockfile, self.config):
if not mirror_exists:
if self.database.get(self.path) is None:
LOG.error("Mirror does not exist!")
return False
return self._fetch(command_args)
Expand Down