Benjamin Schubert pushed to branch bschubert/fix-atomic-move-git-repo at BuildStream / buildstream
Commits:
-
920462bf
by Benjamin Schubert at 2018-11-09T14:50:49Z
1 changed file:
Changes:
... | ... | @@ -68,7 +68,6 @@ details on common configuration options for sources. |
68 | 68 |
The ``pip`` plugin is available since :ref:`format version 16 <project_format_version>`
|
69 | 69 |
"""
|
70 | 70 |
|
71 |
-import errno
|
|
72 | 71 |
import hashlib
|
73 | 72 |
import os
|
74 | 73 |
import re
|
... | ... | @@ -192,13 +191,14 @@ class PipSource(Source): |
192 | 191 |
# process has fetched the sources before us and ensure that we do
|
193 | 192 |
# not raise an error in that case.
|
194 | 193 |
try:
|
195 |
- os.makedirs(self._mirror)
|
|
196 |
- os.rename(package_dir, self._mirror)
|
|
197 |
- except FileExistsError:
|
|
198 |
- return
|
|
194 |
+ utils.move_atomic(package_dir, self._mirror)
|
|
195 |
+ except utils.DirectoryExistsError:
|
|
196 |
+ # Another process has beaten us and has fetched the sources
|
|
197 |
+ # before us.
|
|
198 |
+ pass
|
|
199 | 199 |
except OSError as e:
|
200 |
- if e.errno != errno.ENOTEMPTY:
|
|
201 |
- raise
|
|
200 |
+ raise SourceError("{}: Failed to move downloaded pip packages from '{}' to '{}': {}"
|
|
201 |
+ .format(self, package_dir, self._mirror, e)) from e
|
|
202 | 202 |
|
203 | 203 |
def stage(self, directory):
|
204 | 204 |
with self.timed_activity("Staging Python packages", silent_nested=True):
|