1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-07 10:43:27 -04:00

bugfix: Alignments, prevent duplicate backup alignment file names

This commit is contained in:
torzdf 2024-05-19 11:04:48 +01:00
parent 8c3bc39454
commit 1f4fcff5dd

View file

@ -796,7 +796,15 @@ class _IO():
now = datetime.now().strftime("%Y%m%d_%H%M%S")
src = self._file
split = os.path.splitext(src)
dst = split[0] + "_" + now + split[1]
dst = f"{split[0]}_{now}{split[1]}"
idx = 1
while True:
if not os.path.exists(dst):
break
logger.debug("Backup file %s exists. Incrementing", dst)
dst = f"{split[0]}_{now}({idx}){split[1]}"
idx += 1
logger.info("Backing up original alignments to '%s'", dst)
os.rename(src, dst)
logger.debug("Backed up alignments")