mirror of
https://github.com/zebrajr/faceswap.git
synced 2025-12-06 00:20:09 +01:00
bugfix: Alignments, prevent duplicate backup alignment file names
This commit is contained in:
parent
8c3bc39454
commit
1f4fcff5dd
|
|
@ -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…
Reference in New Issue
Block a user