chat: added check for existing files when creating new filenames

This commit is contained in:
juk0de 2023-09-10 19:18:14 +02:00 committed by Oleksandr Kozachuk
parent cc76da2ab3
commit 864ab7aeb1

View File

@ -62,7 +62,10 @@ def make_file_path(dir_path: Path,
Create a file_path for the given directory using the Create a file_path for the given directory using the
given file_suffix and ID generator function. given file_suffix and ID generator function.
""" """
return dir_path / f"{next_fid():04d}{file_suffix}" file_path = dir_path / f"{next_fid():04d}{file_suffix}"
while file_path.exists():
file_path = dir_path / f"{next_fid():04d}{file_suffix}"
return file_path
def write_dir(dir_path: Path, def write_dir(dir_path: Path,