1111import aiohttp
1212from lxml .etree import fromstring
1313from lxml .html import document_fromstring
14- from pakler import PAK , is_pak_file
14+ from pakler import PAK , Section , is_pak_file
1515from pycramfs import Cramfs
1616from pycramfs .const import MAGIC_BYTES as CRAMFS_MAGIC
1717from PySquashfsImage import SquashFsImage
@@ -146,6 +146,18 @@ def is_local_file(string):
146146 return Path (string ).is_file ()
147147
148148
149+ def get_fs_info (pak : PAK , fs_sections : list [Section ]) -> list [dict [str , str ]]:
150+ result = []
151+ for section in fs_sections :
152+ pak ._fd .seek (section .start )
153+ fs = FileSystem .from_magic (pak ._fd .read (4 ))
154+ result .append ({
155+ "name" : section .name ,
156+ "type" : fs .name .lower () if fs is not None else "unknown"
157+ })
158+ return result
159+
160+
149161async def get_info_from_pak (pak : PAK ):
150162 ha = await asyncio .to_thread (sha256_pak , pak )
151163 fs_sections = [s for s in pak .sections if s .name in FS_SECTIONS ]
@@ -161,7 +173,7 @@ async def get_info_from_pak(pak: PAK):
161173 else :
162174 return {"error" : "Unrecognized image type" , "sha256" : ha }
163175 info = get_info_from_files (files )
164- return {** info , "sha256" : ha }
176+ return {** info , "filesystems" : get_fs_info ( pak , fs_sections ), " sha256" : ha }
165177
166178
167179async def direct_download_url (url ):
0 commit comments