You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by "gtristan (via GitHub)" <gi...@apache.org> on 2023/09/07 05:21:29 UTC

[GitHub] [buildstream] gtristan commented on a diff in pull request #1832: Fix downloadablefile race condition

gtristan commented on code in PR #1832:
URL: https://github.com/apache/buildstream/pull/1832#discussion_r1318095064


##########
src/buildstream/downloadablefilesource.py:
##########
@@ -235,8 +235,12 @@ def _ensure_mirror(self, activity_name: str):
                 return self.ref
 
             # Make sure url-specific mirror dir exists.
-            if not os.path.isdir(self._mirror_dir):
-                os.makedirs(self._mirror_dir)
+            try:
+                os.makedirs(self._mirror_dir, exist_ok=True)

Review Comment:
   This can happen whenever you have 2 separate elements which download the same downloadable file source.
   
   The later call to `os.rename()` below guarantees the required atomicity, but the call to `os.makedirs()` will collide in the case that both sources try to create the directory after both having passed the `not os.path.isdir(self._mirror_dir)` check.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@buildstream.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org