Skip to content

Commit adf9ba2

Browse files
committed
Fixed an issue when "pio package publish" command removes original archive after submitting to the registry // Resolve #3716
1 parent cacddb9 commit adf9ba2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PlatformIO Core 5
1717
- Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)
1818
- Fixed an issue with GCC linker when "native" dev-platform is used in pair with library dependencies (`issue #3669 <https://github.com/platformio/platformio-core/issues/3669>`_)
1919
- Fixed an "AssertionError: ensure_dir_exists" when checking library updates from simultaneous subprocesses (`issue #3677 <https://github.com/platformio/platformio-core/issues/3677>`_)
20+
- Fixed an issue when "pio package publish" command removes original archive after submitting to the registry `issue #3716 <https://github.com/platformio/platformio-core/issues/3716>`_)
2021

2122
5.0.1 (2020-09-10)
2223
~~~~~~~~~~~~~~~~~~

platformio/commands/package.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
# limitations under the License.
1414

1515
import os
16+
import tempfile
1617
from datetime import datetime
1718

1819
import click
1920

21+
from platformio import fs
2022
from platformio.clients.registry import RegistryClient
23+
from platformio.compat import ensure_python3
2124
from platformio.package.meta import PackageSpec, PackageType
2225
from platformio.package.pack import PackagePacker
2326

@@ -77,13 +80,16 @@ def package_pack(package, output):
7780
help="Notify by email when package is processed",
7881
)
7982
def package_publish(package, owner, released_at, private, notify):
80-
p = PackagePacker(package)
81-
archive_path = p.pack()
82-
response = RegistryClient().publish_package(
83-
archive_path, owner, released_at, private, notify
84-
)
85-
os.remove(archive_path)
86-
click.secho(response.get("message"), fg="green")
83+
assert ensure_python3()
84+
with tempfile.TemporaryDirectory() as tmp_dir: # pylint: disable=no-member
85+
with fs.cd(tmp_dir):
86+
p = PackagePacker(package)
87+
archive_path = p.pack()
88+
response = RegistryClient().publish_package(
89+
archive_path, owner, released_at, private, notify
90+
)
91+
os.remove(archive_path)
92+
click.secho(response.get("message"), fg="green")
8793

8894

8995
@cli.command("unpublish", short_help="Remove a pushed package from the registry")

0 commit comments

Comments
 (0)