mirror of
https://github.com/ihaveamac/custom-install.git
synced 2025-12-06 06:41:45 +00:00
custominstall: separate reader creation to get_reader, check against more errors
This commit is contained in:
@@ -26,9 +26,10 @@ if TYPE_CHECKING:
|
|||||||
from events import Events
|
from events import Events
|
||||||
|
|
||||||
from pyctr.crypto import CryptoEngine, Keyslot, load_seeddb, get_seed
|
from pyctr.crypto import CryptoEngine, Keyslot, load_seeddb, get_seed
|
||||||
from pyctr.type.cdn import CDNReader
|
from pyctr.type.cdn import CDNReader, CDNError
|
||||||
from pyctr.type.cia import CIAReader, CIAError
|
from pyctr.type.cia import CIAReader, CIAError
|
||||||
from pyctr.type.ncch import NCCHSection
|
from pyctr.type.ncch import NCCHSection
|
||||||
|
from pyctr.type.tmd import TitleMetadataError
|
||||||
from pyctr.util import roundup
|
from pyctr.util import roundup
|
||||||
|
|
||||||
if platform == 'msys':
|
if platform == 'msys':
|
||||||
@@ -221,21 +222,30 @@ class CustomInstall:
|
|||||||
|
|
||||||
return hasher.digest()
|
return hasher.digest()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_reader(path: 'Union[PathLike, bytes, str]'):
|
||||||
|
if isdir(path):
|
||||||
|
# try the default tmd file
|
||||||
|
reader = CDNReader(join(path, 'tmd'))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
reader = CIAReader(path)
|
||||||
|
except CIAError:
|
||||||
|
# if there was an error with parsing the CIA header,
|
||||||
|
# the file would be tried in CDNReader next (assuming it's a tmd)
|
||||||
|
# any other error should be propagated to the caller
|
||||||
|
reader = CDNReader(path)
|
||||||
|
return reader
|
||||||
|
|
||||||
def prepare_titles(self, paths: 'List[PathLike]'):
|
def prepare_titles(self, paths: 'List[PathLike]'):
|
||||||
readers = []
|
readers = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
self.log(f'Reading {path}')
|
self.log(f'Reading {path}')
|
||||||
if isdir(path):
|
try:
|
||||||
# try the default tmd file
|
reader = self.get_reader(path)
|
||||||
reader = CDNReader(join(path, 'tmd'))
|
except (CIAError, CDNError, TitleMetadataError):
|
||||||
else:
|
self.log(f"Couldn't read {path}, likely corrupt or not a CIA or CDN title")
|
||||||
try:
|
continue
|
||||||
reader = CIAReader(path)
|
|
||||||
except CIAError:
|
|
||||||
# if there was an error with parsing the CIA header,
|
|
||||||
# the file would be tried in CDNReader next (assuming it's a tmd)
|
|
||||||
# any other error should be propagated to the caller
|
|
||||||
reader = CDNReader(path)
|
|
||||||
if reader.tmd.title_id.startswith('00048'): # DSiWare
|
if reader.tmd.title_id.startswith('00048'): # DSiWare
|
||||||
self.log(f'Skipping {reader.tmd.title_id} - DSiWare is not supported')
|
self.log(f'Skipping {reader.tmd.title_id} - DSiWare is not supported')
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user