From f2cd0b0c4a423bdd1e7023a51e92e24043d6574e Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 15 Jul 2022 02:03:41 +0200 Subject: [PATCH] sfx: avoid name collisions across reboots --- scripts/sfx.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/sfx.py b/scripts/sfx.py index 2cb20c8a..c71de9ad 100644 --- a/scripts/sfx.py +++ b/scripts/sfx.py @@ -224,11 +224,15 @@ def unpack(): """unpacks the tar yielded by `data`""" name = "pe-copyparty" tag = "v" + str(STAMP) - withpid = "{}.{}".format(name, os.getpid()) top = tempfile.gettempdir() opj = os.path.join final = opj(top, name) - mine = opj(top, withpid) + for suf in range(0, 9001): + withpid = "{}.{}.{}".format(name, os.getpid(), suf) + mine = opj(top, withpid) + if not os.path.exists(mine): + break + tar = opj(mine, "tar") try: