Skip to content

Commit

Permalink
🐛 Fix docker volumn rename error (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com>
  • Loading branch information
AkkiaS7 and omg-xtao authored Jan 6, 2024
1 parent 0e4a9a6 commit 3ddd16b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pagermaid/update/v1402.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from datetime import datetime
from pathlib import Path
import shutil

data = Path("data")
data.mkdir(exist_ok=True)


def rename(old: Path):
def rename(old: Path, need_backup: bool = True):
if old.exists():
old_file_name = old.name
new = data / old_file_name
if new.exists():
new.unlink()
old.rename(new)
if need_backup and new.exists():
datetime_str = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
backup = data / f"{new.stem}.{datetime_str}{new.suffix}"
shutil.move(new, backup)
shutil.move(old, new)


# move file
Expand All @@ -22,7 +26,7 @@ def rename(old: Path):
rename(config)
# docker
docker = Path("install.lock")
rename(docker)
rename(docker, need_backup=False)
# delete file
# log
log = Path("pagermaid.log.txt")
Expand Down

0 comments on commit 3ddd16b

Please sign in to comment.