Skip to content

Commit

Permalink
bugfix: Alignments, prevent duplicate backup alignment file names
Browse files Browse the repository at this point in the history
  • Loading branch information
torzdf committed May 19, 2024
1 parent 8c3bc39 commit 1f4fcff
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/align/alignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,15 @@ def backup(self) -> None:
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")

0 comments on commit 1f4fcff

Please sign in to comment.