From 572f0d51c4bc0de3516bc7b72f34bf0f8b07f28b Mon Sep 17 00:00:00 2001 From: g1879 Date: Sun, 5 Nov 2023 21:17:20 +0800 Subject: [PATCH] =?UTF-8?q?set.download=5Ffile=5Fname()=E5=A2=9E=E5=8A=A0s?= =?UTF-8?q?uffix=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_units/download_manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DrissionPage/_units/download_manager.py b/DrissionPage/_units/download_manager.py index 5cd27a8..0010119 100644 --- a/DrissionPage/_units/download_manager.py +++ b/DrissionPage/_units/download_manager.py @@ -139,7 +139,7 @@ class BrowserDownloadManager(object): settings = TabDownloadSettings(tab_id if tab_id in TabDownloadSettings.TABS else self._page.tab_id) if settings.rename: if settings.suffix is not None: - name = f'{settings.rename}.{settings.suffix}' + name = f'{settings.rename}.{settings.suffix}' if settings.suffix else settings.rename else: tmp = kwargs['suggestedFilename'].rsplit('.', 1) @@ -152,7 +152,9 @@ class BrowserDownloadManager(object): settings.suffix = None elif settings.suffix is not None: - name = f'{kwargs["suggestedFilename"].rsplit(".", 1)[0]}.{settings.suffix}' + name = kwargs["suggestedFilename"].rsplit(".", 1)[0] + if settings.suffix: + name = f'{name}.{settings.suffix}' settings.suffix = None else: