Skip to content

Add filelock for git operations#28

Open
therazix wants to merge 1 commit into
fvagner-update-tmt-versionfrom
fvagner-filelock
Open

Add filelock for git operations#28
therazix wants to merge 1 commit into
fvagner-update-tmt-versionfrom
fvagner-filelock

Conversation

@therazix
Copy link
Copy Markdown
Contributor

This PR wraps all git operations in get_git_repository with a per-repository FileLock to prevent concurrent tasks from potentially corrupting a shared local clone. Also, if fetching from the remote fails, the repository is automatically wiped and re-cloned to ensure a clean state.

@therazix therazix requested review from janhavlin and psss May 13, 2026 15:20
@happz happz added this to planning May 20, 2026
@github-project-automation github-project-automation Bot moved this to backlog in planning May 20, 2026
@happz happz added the bug Something isn't working label May 20, 2026
@happz happz moved this from backlog to review in planning May 20, 2026
Comment on lines +97 to +98
rmtree(destination, ignore_errors=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like a no op because this is gated by destination.exists. In fact, why not just move that check inside here?

Comment on lines 94 to 95
# Get unique path
destination = get_unique_clone_path(url)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks bad. You already calculated the destination in previous steps and made it linked to a file lock. Make sure the destination in the calling function is used instead

Comment on lines -104 to +130
# Fetch remote refs
_fetch_remote(common, destination, logger)
try:
# Fetch remote refs
_fetch_remote(common, destination, logger)
except GeneralError:
logger.warning("Unable to fetch remote repository. Trying to clone again.")
clone_repository(url, logger)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can elaborate when this can occur and why re-cloning would help? Also putting the rmtree here is more understandable.

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

Labels

bug Something isn't working

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

3 participants