From 99412156438ba29786e94d21d16cef7f91dc243d Mon Sep 17 00:00:00 2001 From: Serene-Arc Date: Wed, 17 Mar 2021 15:49:07 +1000 Subject: [PATCH] Fix index being added to single resources --- bulkredditdownloader/file_name_formatter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bulkredditdownloader/file_name_formatter.py b/bulkredditdownloader/file_name_formatter.py index 1950306..f36284e 100644 --- a/bulkredditdownloader/file_name_formatter.py +++ b/bulkredditdownloader/file_name_formatter.py @@ -68,9 +68,12 @@ class FileNameFormatter: def format_resource_paths(self, resources: list[Resource], destination_directory: Path) -> list[tuple[Path, Resource]]: out = [] - for i, res in enumerate(resources, start=1): - logger.log(9, f'Formatting filename with index {i}') - out.append((self.format_path(res, destination_directory, i), res)) + if len(resources) == 1: + out.append((self.format_path(resources[0], destination_directory, None), resources[0])) + else: + for i, res in enumerate(resources, start=1): + logger.log(9, f'Formatting filename with index {i}') + out.append((self.format_path(res, destination_directory, i), res)) return out @ staticmethod