Skip to content

Commit

Permalink
Handle SameFileError in migration module.
Browse files Browse the repository at this point in the history
  • Loading branch information
emcek committed Jan 2, 2024
1 parent 4e56cea commit 45d49dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dcspy/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os import makedirs
from pathlib import Path
from pprint import pformat
from shutil import copy
from shutil import SameFileError, copy
from typing import Callable, Iterator, Union

from packaging import version
Expand Down Expand Up @@ -151,4 +151,7 @@ def _copy_file(filename: str, to_path: Path, force=False) -> None:
:param force: force to overwrite existing file
"""
if not Path(to_path / filename).is_file() or force:
copy(src=DEFAULT_YAML_FILE.parent / filename, dst=to_path)
try:
copy(src=DEFAULT_YAML_FILE.parent / filename, dst=to_path)
except SameFileError:
pass

0 comments on commit 45d49dd

Please sign in to comment.