Fixed an issue when "pio package publish" command removes original archive after submitting to the registry // Resolve #3716

This commit is contained in:
Ivan Kravets
2020-10-28 22:52:48 +02:00
parent cacddb9abb
commit adf9ba29df
2 changed files with 14 additions and 7 deletions

View File

@ -17,6 +17,7 @@ PlatformIO Core 5
- Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_) - Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)
- 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>`_) - 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>`_)
- Fixed an "AssertionError: ensure_dir_exists" when checking library updates from simultaneous subprocesses (`issue #3677 <https://github.com/platformio/platformio-core/issues/3677>`_) - Fixed an "AssertionError: ensure_dir_exists" when checking library updates from simultaneous subprocesses (`issue #3677 <https://github.com/platformio/platformio-core/issues/3677>`_)
- 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>`_)
5.0.1 (2020-09-10) 5.0.1 (2020-09-10)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

View File

@ -13,11 +13,14 @@
# limitations under the License. # limitations under the License.
import os import os
import tempfile
from datetime import datetime from datetime import datetime
import click import click
from platformio import fs
from platformio.clients.registry import RegistryClient from platformio.clients.registry import RegistryClient
from platformio.compat import ensure_python3
from platformio.package.meta import PackageSpec, PackageType from platformio.package.meta import PackageSpec, PackageType
from platformio.package.pack import PackagePacker from platformio.package.pack import PackagePacker
@ -77,13 +80,16 @@ def package_pack(package, output):
help="Notify by email when package is processed", help="Notify by email when package is processed",
) )
def package_publish(package, owner, released_at, private, notify): def package_publish(package, owner, released_at, private, notify):
p = PackagePacker(package) assert ensure_python3()
archive_path = p.pack() with tempfile.TemporaryDirectory() as tmp_dir: # pylint: disable=no-member
response = RegistryClient().publish_package( with fs.cd(tmp_dir):
archive_path, owner, released_at, private, notify p = PackagePacker(package)
) archive_path = p.pack()
os.remove(archive_path) response = RegistryClient().publish_package(
click.secho(response.get("message"), fg="green") 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") @cli.command("unpublish", short_help="Remove a pushed package from the registry")