Today every call to repository.Open()
return a repository and then caller can RLock
or WLock
but sometimes it’s too late.
To bypass that, I made a cacheLock
which permit to freeze all cal to reposotory during an operation (creation for example). But no other code can run during a cacheLock because they will not acquire cacheLock.
I think wee need to decouple:
When a repository write, others open repository need to know that and reload (invalid cache?) of current worktree.
All of this lock state should be managed outside of a repo by the manager. Like that it not impact the way repository works.