forked from platformio/platformio-core
Check item after unpacking only if not symbolic link
This commit is contained in:
@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from os import chmod
|
from os import chmod
|
||||||
from os.path import exists, join
|
from os.path import exists, islink, join
|
||||||
from tarfile import open as tarfile_open
|
from tarfile import open as tarfile_open
|
||||||
from time import mktime
|
from time import mktime
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
@ -50,9 +50,10 @@ class TARArchive(ArchiveBase):
|
|||||||
def get_items(self):
|
def get_items(self):
|
||||||
return self._afo.getmembers()
|
return self._afo.getmembers()
|
||||||
|
|
||||||
# def after_extract(self, item, dest_dir):
|
def after_extract(self, item, dest_dir):
|
||||||
# if not exists(join(dest_dir, item.name)):
|
item_path = join(dest_dir, item.name)
|
||||||
# raise exception.ExtractArchiveItemError(item.name, dest_dir)
|
if not islink(item_path) and not exists(item_path):
|
||||||
|
raise exception.ExtractArchiveItemError(item.name, dest_dir)
|
||||||
|
|
||||||
|
|
||||||
class ZIPArchive(ArchiveBase):
|
class ZIPArchive(ArchiveBase):
|
||||||
@ -76,8 +77,9 @@ class ZIPArchive(ArchiveBase):
|
|||||||
return self._afo.infolist()
|
return self._afo.infolist()
|
||||||
|
|
||||||
def after_extract(self, item, dest_dir):
|
def after_extract(self, item, dest_dir):
|
||||||
# if not exists(join(dest_dir, item.filename)):
|
item_path = join(dest_dir, item.filename)
|
||||||
# raise exception.ExtractArchiveItemError(item.filename, dest_dir)
|
if not islink(item_path) and not exists(item_path):
|
||||||
|
raise exception.ExtractArchiveItemError(item.filename, dest_dir)
|
||||||
self.preserve_permissions(item, dest_dir)
|
self.preserve_permissions(item, dest_dir)
|
||||||
self.preserve_mtime(item, dest_dir)
|
self.preserve_mtime(item, dest_dir)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user