forked from platformio/platformio-core
Check package structure after unpacking and raise error when antivirus tool blocks PlatformIO package manager // Resolve #1462
This commit is contained in:
@@ -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):
|
||||
|
Reference in New Issue
Block a user