Skip to content

Commit

Permalink
Fix potential atlas file race condition (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo authored Feb 27, 2024
1 parent f748eea commit 5867423
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xcp_d/utils/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,8 @@ def copy_atlas(name_source, in_file, output_dir, atlas):
atlas_out_dir = os.path.join(output_dir, f"xcp_d/atlases/atlas-{atlas}")
os.makedirs(atlas_out_dir, exist_ok=True)
out_atlas_file = os.path.join(atlas_out_dir, atlas_basename)
shutil.copyfile(in_file, out_atlas_file)
# Don't copy the file if it exists, to prevent any race conditions between parallel processes.
if not os.path.isfile(out_atlas_file):
shutil.copyfile(in_file, out_atlas_file)

return out_atlas_file

0 comments on commit 5867423

Please sign in to comment.