From adf9ba29df7ccc1da1ec6c434e6a187af239b937 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 28 Oct 2020 22:52:48 +0200 Subject: [PATCH] Fixed an issue when "pio package publish" command removes original archive after submitting to the registry // Resolve #3716 --- HISTORY.rst | 1 + platformio/commands/package.py | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index d42543d6..47104ec3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,7 @@ PlatformIO Core 5 - Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 `_) - Fixed an issue with GCC linker when "native" dev-platform is used in pair with library dependencies (`issue #3669 `_) - Fixed an "AssertionError: ensure_dir_exists" when checking library updates from simultaneous subprocesses (`issue #3677 `_) +- Fixed an issue when "pio package publish" command removes original archive after submitting to the registry `issue #3716 `_) 5.0.1 (2020-09-10) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/commands/package.py b/platformio/commands/package.py index f62362ff..bda36570 100644 --- a/platformio/commands/package.py +++ b/platformio/commands/package.py @@ -13,11 +13,14 @@ # limitations under the License. import os +import tempfile from datetime import datetime import click +from platformio import fs from platformio.clients.registry import RegistryClient +from platformio.compat import ensure_python3 from platformio.package.meta import PackageSpec, PackageType from platformio.package.pack import PackagePacker @@ -77,13 +80,16 @@ def package_pack(package, output): help="Notify by email when package is processed", ) def package_publish(package, owner, released_at, private, notify): - p = PackagePacker(package) - archive_path = p.pack() - response = RegistryClient().publish_package( - archive_path, owner, released_at, private, notify - ) - os.remove(archive_path) - click.secho(response.get("message"), fg="green") + assert ensure_python3() + with tempfile.TemporaryDirectory() as tmp_dir: # pylint: disable=no-member + with fs.cd(tmp_dir): + p = PackagePacker(package) + archive_path = p.pack() + response = RegistryClient().publish_package( + archive_path, owner, released_at, private, notify + ) + os.remove(archive_path) + click.secho(response.get("message"), fg="green") @cli.command("unpublish", short_help="Remove a pushed package from the registry")