mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
feat(tools): handle symlinks correctly for take command (#240)
This commit is contained in:
parent
c863d24695
commit
0ba8cd41de
1 changed files with 8 additions and 3 deletions
|
@ -4,8 +4,10 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
|
import shutil
|
||||||
import structlog
|
import structlog
|
||||||
import json
|
import json
|
||||||
|
import os.path
|
||||||
|
|
||||||
from . import core
|
from . import core
|
||||||
|
|
||||||
|
@ -60,9 +62,12 @@ def take() -> None:
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
oldverf.rename(
|
if os.path.islink(oldverf):
|
||||||
oldverf.with_name(oldverf.name + '~'),
|
shutil.copy(oldverf, oldverf.with_name(oldverf.name + '~'))
|
||||||
)
|
else:
|
||||||
|
oldverf.rename(
|
||||||
|
oldverf.with_name(oldverf.name + '~'),
|
||||||
|
)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
core.write_verfile(oldverf, oldvers)
|
core.write_verfile(oldverf, oldvers)
|
||||||
|
|
Loading…
Add table
Reference in a new issue