Skip to content

Commit d4b9510

Browse files
committed
Don't create solution files if they already exist
1 parent f3e1392 commit d4b9510

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

solution_runner/commands/setup_command.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ def _create_files(year_solutions_directory: Path, day: str):
124124
:param day: day of the challenge
125125
"""
126126
solutions_directory = year_solutions_directory / f"d{day}"
127-
solutions_directory.mkdir()
127+
try:
128+
solutions_directory.mkdir()
129+
except FileExistsError as error:
130+
if error.errno == errno.EEXIST:
131+
return # If solution directory already exists, don't create new solution files.
132+
raise
128133
for part in consts.SOLUTION_PARTS:
129134
filepath = (solutions_directory / part).with_suffix(FileExtensions.PYTHON)
130135
shutil.copy(consts.SOLUTION_FILE_TEMPLATE_PATH, filepath)

0 commit comments

Comments
 (0)