Check package structure after unpacking and raise error when antivirus tool blocks PlatformIO package manager // Resolve #1462

This commit is contained in:
Ivan Kravets
2018-07-13 01:54:37 +03:00
parent 735cfbf850
commit 44a926b30a
4 changed files with 21 additions and 5 deletions

View File

@ -15,6 +15,10 @@ PlatformIO 3.0
- Check maximum allowed "program" and "data" sizes before uploading/programming
(`issue #1412 <https://github.com/platformio/platformio-core/issues/1412>`_)
* Check package structure after unpacking and raise error when antivirus tool
blocks PlatformIO package manager
(`issue #1462 <https://github.com/platformio/platformio-core/issues/1462>`_)
3.5.4 (2018-07-03)
~~~~~~~~~~~~~~~~~~

2
docs

Submodule docs updated: 14ee40368f...e3330b7e33

View File

@ -102,6 +102,13 @@ class PackageInstallError(PlatformioException):
"Please try this solution -> http://bit.ly/faq-package-manager")
class ExtractArchiveItemError(PlatformioException):
MESSAGE = (
"Could not extract `{0}` to `{1}`. Try to disable antivirus "
"tool or check this solution -> http://bit.ly/faq-package-manager")
class FDUnrecognizedStatusCode(PlatformioException):
MESSAGE = "Got an unrecognized status code '{0}' when downloaded {1}"

View File

@ -13,15 +13,14 @@
# limitations under the License.
from os import chmod
from os.path import join
from os.path import exists, join
from tarfile import open as tarfile_open
from time import mktime
from zipfile import ZipFile
import click
from platformio import util
from platformio.exception import UnsupportedArchiveType
from platformio import exception, util
class ArchiveBase(object):
@ -51,6 +50,10 @@ class TARArchive(ArchiveBase):
def get_items(self):
return self._afo.getmembers()
def after_extract(self, item, dest_dir):
if not exists(join(dest_dir, item.name)):
raise exception.ExtractArchiveItemError(item.name, dest_dir)
class ZIPArchive(ArchiveBase):
@ -73,6 +76,8 @@ class ZIPArchive(ArchiveBase):
return self._afo.infolist()
def after_extract(self, item, dest_dir):
if not exists(join(dest_dir, item.filename)):
raise exception.ExtractArchiveItemError(item.filename, dest_dir)
self.preserve_permissions(item, dest_dir)
self.preserve_mtime(item, dest_dir)
@ -89,7 +94,7 @@ class FileUnpacker(object):
elif self.archpath.lower().endswith(".zip"):
self._unpacker = ZIPArchive(self.archpath)
if not self._unpacker:
raise UnsupportedArchiveType(self.archpath)
raise exception.UnsupportedArchiveType(self.archpath)
return self
def __exit__(self, *args):