mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge branch '2.2' into 3.0
# Conflicts: # .github/workflows/testing.yml # CHANGELOG # README.md # dev-requirements.txt # gns3server/compute/docker/docker_vm.py # gns3server/controller/export_project.py # gns3server/controller/import_project.py # gns3server/controller/project.py # gns3server/crash_report.py # gns3server/static/web-ui/index.html # gns3server/static/web-ui/main.df8c319a3da6fb0e3629.js # gns3server/version.py # requirements.txt # setup.py # tests/compute/docker/test_docker_vm.py # tests/controller/test_import_project.py
This commit is contained in:
24 files changed
+648
-312
No files matched your search
@@ -195,14 +195,17 @@ class ZipFile(zipfile.ZipFile):
|
||||
self._comment = comment
|
||||
self._didModify = True
|
||||
|
||||
async def data_generator(self, path):
|
||||
async def data_generator(self, path, islink=False):
|
||||
|
||||
async with aiofiles.open(path, "rb") as f:
|
||||
while True:
|
||||
part = await f.read(self._chunksize)
|
||||
if not part:
|
||||
break
|
||||
yield part
|
||||
if islink:
|
||||
yield os.readlink(path).encode()
|
||||
else:
|
||||
async with aiofiles.open(path, "rb") as f:
|
||||
while True:
|
||||
part = await f.read(self._chunksize)
|
||||
if not part:
|
||||
break
|
||||
yield part
|
||||
return
|
||||
|
||||
async def _run_in_executor(self, task, *args, **kwargs):
|
||||
@@ -268,12 +271,13 @@ class ZipFile(zipfile.ZipFile):
|
||||
raise ValueError("either (exclusively) filename or iterable shall be not None")
|
||||
|
||||
if filename:
|
||||
st = os.stat(filename)
|
||||
st = os.stat(filename, follow_symlinks=False)
|
||||
isdir = stat.S_ISDIR(st.st_mode)
|
||||
islink = stat.S_ISLNK(st.st_mode)
|
||||
mtime = time.localtime(st.st_mtime)
|
||||
date_time = mtime[0:6]
|
||||
else:
|
||||
st, isdir, date_time = None, False, time.localtime()[0:6]
|
||||
st, isdir, islink, date_time = None, False, False, time.localtime()[0:6]
|
||||
# Create ZipInfo instance to store file information
|
||||
if arcname is None:
|
||||
arcname = filename
|
||||
@@ -331,7 +335,7 @@ class ZipFile(zipfile.ZipFile):
|
||||
|
||||
file_size = 0
|
||||
if filename:
|
||||
async for buf in self.data_generator(filename):
|
||||
async for buf in self.data_generator(filename, islink):
|
||||
file_size = file_size + len(buf)
|
||||
CRC = zipfile.crc32(buf, CRC) & 0xFFFFFFFF
|
||||
if cmpr:
|
||||
|
||||
Reference in new issue
Block a user