From f360421862ef9a7231f5ce15f61802bc9d0ea242 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Mon, 11 Dec 2023 13:40:41 -0800 Subject: [PATCH] Fixes Python 3.8 compatabiliyt --- CHANGELOG.md | 8 ++++++++ src/gotenberg_client/_base.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4f1341..c0d39e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Implemented an internal workaround for older Gotenberg versions and their handling of non-latin filenames. + - When detected, the files will be copied into a temporary directory and the filename cleaned + - Gotenberg 8.0.0 will start implementing something similar once released + ## [0.4.0] - 2023-12-04 ### Changed diff --git a/src/gotenberg_client/_base.py b/src/gotenberg_client/_base.py index d8a6c11..2c46707 100644 --- a/src/gotenberg_client/_base.py +++ b/src/gotenberg_client/_base.py @@ -113,7 +113,7 @@ def _add_file_map(self, filepath: Path, name: Optional[str] = None) -> None: logger.warning(f"filename {name} includes non-ascii characters, compensating for Gotenberg") tmp_dir = self._stack.enter_context(TemporaryDirectory()) # Filename can be fixed, the directory is random - new_path = Path(tmp_dir) / Path(name).with_stem("clean-filename-copy") + new_path = Path(tmp_dir) / Path(name).with_name(f"clean-filename-copy{filepath.suffix}") logger.warning(f"New path {new_path}") new_path.write_bytes(filepath.read_bytes()) filepath = new_path