Reset seek on unwrapped zip

If the zip payload is passed through
as-is, then make sure to seek if
the filehandle is open.

Change-Id: I04702da72d63b4edd7841e1b4f55704a92522ba9
This commit is contained in:
Jarrod Johnson 2023-07-27 15:18:30 -04:00
parent b1a693a0e7
commit 9c84b8ad50
2 changed files with 8 additions and 0 deletions

View File

@ -1994,8 +1994,10 @@ class XCCClient(IMMClient):
z = None
wrappedfilename = None
uxzcount = 0
needseek = False
if data and hasattr(data, 'read'):
if zipfile.is_zipfile(data):
needseek = True
z = zipfile.ZipFile(data)
else:
data.seek(0)
@ -2010,6 +2012,8 @@ class XCCClient(IMMClient):
if uxzcount == 1 and wrappedfilename:
filename = os.path.basename(wrappedfilename)
data = z.open(wrappedfilename)
elif needseek:
data.seek(0)
upurl = usd['HttpPushUri']
self.grab_redfish_response_with_status(
'/redfish/v1/UpdateService',

View File

@ -1200,8 +1200,10 @@ class OEMHandler(generic.OEMHandler):
z = None
wrappedfilename = None
uxzcount = 0
needseek = False
if data and hasattr(data, 'read'):
if zipfile.is_zipfile(data):
needseek = True
z = zipfile.ZipFile(data)
else:
data.seek(0)
@ -1216,6 +1218,8 @@ class OEMHandler(generic.OEMHandler):
if uxzcount == 1 and wrappedfilename:
filename = os.path.basename(wrappedfilename)
data = z.open(wrappedfilename)
elif needseek:
data.seek(0)
upurl = usd['HttpPushUri']
self._do_web_request(
'/redfish/v1/UpdateService',