codeforamerica / chime

A city-focused content management system
http://chimecms.org/
BSD 3-Clause "New" or "Revised" License
35 stars 12 forks source link

Introduce per-directory exclusive lock for checkouts #459

Open migurski opened 9 years ago

migurski commented 9 years ago

Closes #398; should be scoped to individual users.

Lock should be exclusive and blocking (with a timeout?), would prevent this exception:

2015-08-10 17:05:00,650 - chime.view_functions - ERROR - 'git checkout mrzpgtqzh' returned exit status 128: fatal: Unable to create '/var/opt/chime-work/repo-e9f809ca-william-persona-org-codeforamerica-org/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
Traceback (most recent call last):
 File "/home/ubuntu/chime/chime/view_functions.py", line 452, in decorated_function
   return route_function(*args, **kwargs)
 File "/home/ubuntu/chime/chime/view_functions.py", line 505, in decorated_function
   return route_function(*args, **kwargs)
 File "/home/ubuntu/chime/chime/view_functions.py", line 577, in decorated_function
   branch.checkout()
 File "/usr/local/lib/python2.7/dist-packages/git/refs/head.py", line 218, in checkout
   self.repo.git.checkout(self, **kwargs)
 File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 227, in <lambda>
   return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
 File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 456, in _call_process
   return self.execute(call, **_kwargs)
 File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 377, in execute
   raise GitCommandError(command, status, stderr_value)
GitCommandError: 'git checkout mrzpgtqzh' returned exit status 128: fatal: Unable to create '/var/opt/chime-work/repo-e9f809ca-william-persona-org-codeforamerica-org/.git/index.lock': File exists.