diff options
author | Daniele Esposti <daniele.esposti@gmail.com> | 2016-09-14 10:23:34 +0100 |
---|---|---|
committer | Daniele Esposti <daniele.esposti@gmail.com> | 2016-09-14 10:23:34 +0100 |
commit | 6dfc870cffcfa7ca29e30301fff256e4e5b181f3 (patch) | |
tree | 8e8d1bcff740f7f6c4280bb696ddfbd31f50dfb3 | |
parent | 547e6f0e2e9ace80e6d6b08db3c15fe91efe880f (diff) | |
download | gitpython-6dfc870cffcfa7ca29e30301fff256e4e5b181f3.tar.gz |
No need to create the lock file beforehand
-rw-r--r-- | git/util.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/git/util.py b/git/util.py index fff8ddc0..8d97242c 100644 --- a/git/util.py +++ b/git/util.py @@ -564,20 +564,14 @@ class LockFile(object): lock_file = self._lock_file_path() - # Create lock file + # Create file and lock try: - open(lock_file, 'a').close() - except OSError as e: - # Silence error only if file exists - if e.errno != 17: # 17 -> File exists - raise - - try: - fd = os.open(lock_file, os.O_WRONLY, 0) - flock(fd, LOCK_EX | LOCK_NB) + fd = os.open(lock_file, os.O_CREAT, 0) except OSError as e: raise IOError(str(e)) + flock(fd, LOCK_EX | LOCK_NB) + self._file_descriptor = fd self._owns_lock = True |