Skip to content

Commit

Permalink
Replace some os.mkdir with os.makedirs
Browse files Browse the repository at this point in the history
These are using "if not exists create" and that can race unless
makedirs with exist_ok is used.
  • Loading branch information
timj committed Jan 22, 2024
1 parent 5d2f8ce commit 5bfc940
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions python/eups/db/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def declare(self, product):

# seal the deal
if not os.path.exists(pdir):
os.mkdir(pdir)
os.makedirs(pdir, exist_ok=True)

if prod.dir:
trimDir = prod.stackRoot()
Expand Down Expand Up @@ -725,5 +725,3 @@ def _cmp_str(a, b):
if a < b: return -1
if a > b: return 1
return 0


2 changes: 1 addition & 1 deletion python/eups/distrib/eupspkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def initServerTree(self, serverDir):
# Create the tags storage directory
tagsDir = os.path.join(serverDir, 'tags')
if not os.path.exists(tagsDir):
os.mkdir(tagsDir)
os.makedirs(tagsDir, exist_ok=True)


def getTaggedReleasePath(self, tag, flavor=None):
Expand Down
2 changes: 1 addition & 1 deletion python/eups/distrib/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def createPacmanDir(self, pacmanDir):
pacman -install http://dev.lsstcorp.org/pkgs/pm:LSSTinit
"""
if not os.path.isdir(pacmanDir):
os.mkdir(pacmanDir)
os.makedirs(pacmanDir, exist_ok=True)

def cleanPackage(self, product, version, productRoot, location):
"""remove any distribution-specific remnants of a package installation.
Expand Down
2 changes: 1 addition & 1 deletion python/eups/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def createTempDir(path):
dir = os.path.join(dir, d)

if not os.path.isdir(dir):
os.mkdir(dir)
os.makedirs(dir, exist_ok=True)
os.chmod(dir, 0o777)

return path
Expand Down

0 comments on commit 5bfc940

Please sign in to comment.