Skip to content

Commit

Permalink
Merge pull request #1081 from googlefonts/more-careful-cleanup
Browse files Browse the repository at this point in the history
[fontc] Be more defensive during cleanup
  • Loading branch information
m4rc1e authored Feb 5, 2025
2 parents d4e223a + 05afc84 commit 9d9c32e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Lib/gftools/builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,16 @@ def clean(self):
if os.path.exists(file):
os.remove(file)

if os.path.exists("instance_ufos"):
shutil.rmtree("instance_ufos")
# in the fontc/crater case it's possible that multiple instances of
# gftools builder are running at once, in the same directory,
# in which case we don't want to delete this out from under another process.
# since we should have deleted our own .ninja file above, if any still
# exist we will assume another instance of gftools is running.
if not any(path.endswith("ninja") for path in os.listdir()):
if os.path.exists("instance_ufos"):
shutil.rmtree("instance_ufos")
else:
print("another .ninja file exists, leaving instance_ufos in place")

print("Done cleaning up temporary files")
else:
Expand Down

0 comments on commit 9d9c32e

Please sign in to comment.