The "Teams_OSX.pkg" file is always reported as corrupt on our MAUCacheAdmin installations which causes it to redownload each run. I think I figured it out as due to how the GetDownloadSize function returns the online file size.
The Teams CDN download link (https://statics.teams.cdn.office.net/production-osx/1.5.00.11157/Teams_osx.pkg as of today) returns the following to the GetDownloadSize function's CONTENTHTTPLENGTH=$(curl --head -s $URL | grep -i 'Content-Length' | cut -d ' ' -f2) line:
Note the second line which is coming from the access-control-expose-headers line being returned by the Teams CDN and subsequently being included in the CONTENTHTTPLENGTH result due to grep finding Content-Length twice.
If you run the exact same CONTENTHTTPLENGTH command against a standard Office CDN URL (let's say https://officecdnmac.microsoft.com/pr/C1297A47-86C4-4C1F-97FA-950631F94777/MacAutoupdate/Microsoft_Word_16.63.22071301_Updater.pkg) it returns only a single line with the file size, as expected.
What really trips up the GetDownloadSize function is the next part which strips out everything but numbers: CONTENTLENGTH=$(echo ${CONTENTHTTPLENGTH//[!0-9]/})
Normally this would work but because there's that extra line and it includes Content-MD5 within it, all of a sudden our Teams download size becomes 1105468995 and since that's obviously wrong when compared to the actual downloaded file size the pkg is flagged as corrupt.
The quickest fix (not sure about any potential knock-on effects though) appears to be changing the grep command within GetDownloadSize to look for Content-Length: —including the colon because it is present in the expected Content-Length: line of the headers (from both CDNs) but not the access-control-expose-headers line from the Teams CDN.
With the colon in there MAUCacheAdmin retrieves a single line of content-length from the Teams CDN and doesn't add the extra 5 to the reported download size, resulting in no more incorrectly-reported corruption.
The "Teams_OSX.pkg" file is always reported as corrupt on our MAUCacheAdmin installations which causes it to redownload each run. I think I figured it out as due to how the
GetDownloadSize
function returns the online file size.The Teams CDN download link (
https://statics.teams.cdn.office.net/production-osx/1.5.00.11157/Teams_osx.pkg
as of today) returns the following to theGetDownloadSize
function'sCONTENTHTTPLENGTH=$(curl --head -s $URL | grep -i 'Content-Length' | cut -d ' ' -f2)
line:Note the second line which is coming from the
access-control-expose-headers
line being returned by the Teams CDN and subsequently being included in theCONTENTHTTPLENGTH
result due to grep findingContent-Length
twice.If you run the exact same
CONTENTHTTPLENGTH
command against a standard Office CDN URL (let's sayhttps://officecdnmac.microsoft.com/pr/C1297A47-86C4-4C1F-97FA-950631F94777/MacAutoupdate/Microsoft_Word_16.63.22071301_Updater.pkg
) it returns only a single line with the file size, as expected.What really trips up the
GetDownloadSize
function is the next part which strips out everything but numbers:CONTENTLENGTH=$(echo ${CONTENTHTTPLENGTH//[!0-9]/})
Normally this would work but because there's that extra line and it includes
Content-MD5
within it, all of a sudden our Teams download size becomes 1105468995 and since that's obviously wrong when compared to the actual downloaded file size the pkg is flagged as corrupt.The quickest fix (not sure about any potential knock-on effects though) appears to be changing the grep command within
GetDownloadSize
to look forContent-Length:
—including the colon because it is present in the expectedContent-Length:
line of the headers (from both CDNs) but not theaccess-control-expose-headers
line from the Teams CDN.With the colon in there MAUCacheAdmin retrieves a single line of content-length from the Teams CDN and doesn't add the extra 5 to the reported download size, resulting in no more incorrectly-reported corruption.