Rearrange logic for incrementals

* Require incremental arg and parse it once outside loop.
This commit is contained in:
Tom Marshall 2022-09-02 10:23:56 -07:00
parent 6c7cd369fa
commit 8ca5efb675
1 changed files with 19 additions and 18 deletions

View File

@ -165,6 +165,11 @@ def find_roms(device=None, buildtype=None, incremental=None):
cf.close() cf.close()
cf = None cf = None
try:
req_incr_stamp = incremental_stamp(incremental)
except Exception as e:
raise RuntimeError("Failed to parse request incremental field: %s" % (e))
roms = [] roms = []
for k, v in cache.items(): for k, v in cache.items():
try: try:
@ -177,24 +182,20 @@ def find_roms(device=None, buildtype=None, incremental=None):
continue continue
if buildtype and props['buildtype'] != buildtype: if buildtype and props['buildtype'] != buildtype:
continue continue
if incremental:
if 'incrbase' in props: try:
# Incremental ota_incr_stamp = incremental_stamp(props['incremental'])
if incremental != props['incrbase']: except ValueError:
continue dbg("Failed to parse cache incremental field")
else: continue
# Full
try: if 'incrbase' in props:
req_incr_stamp = incremental_stamp(incremental) # Incremental
except ValueError: if incremental != props['incrbase']:
continue continue
try:
ota_incr_stamp = incremental_stamp(props['incremental']) if ota_incr_stamp <= req_incr_stamp:
except ValueError: continue
dbg("Failed to parse cache incremental field")
continue
if ota_incr_stamp <= req_incr_stamp:
continue
roms.append(v) roms.append(v)