mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Return md5sum and filesize in the list of images
Ref https://github.com/GNS3/gns3-gui/issues/1590
This commit is contained in:
10 files changed
+49
-18
No files matched your search
@@ -483,7 +483,9 @@ class BaseManager:
|
||||
path = os.path.relpath(os.path.join(root, filename), img_dir)
|
||||
images.append({
|
||||
"filename": filename,
|
||||
"path": path})
|
||||
"path": path,
|
||||
"md5sum": md5sum(os.path.join(root, filename)),
|
||||
"filesize": os.stat(os.path.join(root, filename)).st_size})
|
||||
return images
|
||||
|
||||
def get_images_directory(self):
|
||||
@@ -507,7 +509,7 @@ class BaseManager:
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(tmp_path, 'wb+') as f:
|
||||
while True:
|
||||
packet = yield from stream.read(512)
|
||||
packet = yield from stream.read(4096)
|
||||
if not packet:
|
||||
break
|
||||
f.write(packet)
|
||||
|
||||
@@ -33,6 +33,7 @@ import glob
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
from gns3server.utils.interfaces import interfaces, is_interface_up
|
||||
from gns3server.utils.images import md5sum
|
||||
from gns3server.utils.asyncio import wait_run_in_executor
|
||||
from gns3server.utils import parse_version
|
||||
from uuid import UUID, uuid4
|
||||
@@ -712,6 +713,9 @@ class Dynamips(BaseManager):
|
||||
continue
|
||||
# valid IOS images must start with the ELF magic number, be 32-bit, big endian and have an ELF version of 1
|
||||
if elf_header_start == b'\x7fELF\x01\x02\x01':
|
||||
path = os.path.relpath(path, image_dir)
|
||||
images.append({"filename": filename, "path": path})
|
||||
images.append({"filename": filename,
|
||||
"path": os.path.relpath(path, image_dir),
|
||||
"md5sum": md5sum(path),
|
||||
"filesize": os.stat(path).st_size
|
||||
})
|
||||
return images
|
||||
Reference in new issue
Block a user