Skip to content

Commit 0ba8cd4

Browse files
authored
feat(tools): handle symlinks correctly for take command (#240)
1 parent c863d24 commit 0ba8cd4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

nvchecker/tools.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
import sys
66
import argparse
7+
import shutil
78
import structlog
89
import json
10+
import os.path
911

1012
from . import core
1113

@@ -60,9 +62,12 @@ def take() -> None:
6062
sys.exit(2)
6163

6264
try:
63-
oldverf.rename(
64-
oldverf.with_name(oldverf.name + '~'),
65-
)
65+
if os.path.islink(oldverf):
66+
shutil.copy(oldverf, oldverf.with_name(oldverf.name + '~'))
67+
else:
68+
oldverf.rename(
69+
oldverf.with_name(oldverf.name + '~'),
70+
)
6671
except FileNotFoundError:
6772
pass
6873
core.write_verfile(oldverf, oldvers)

0 commit comments

Comments
 (0)