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:
parent
8c3bc39454
commit
1f4fcff5dd
1 changed files with 9 additions and 1 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue