🐛 Fix dependencies check in patchmanifest verification

This commit is contained in:
C-3PO 2018-07-08 21:34:51 +02:00
parent 5574da3189
commit 25d8994593
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -28,8 +28,20 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product
//<Dependencies />
const Dependencies = PatchManifest.elements[0];
if (Dependencies.type !== 'element' || Dependencies.name !== 'Dependencies' || Dependencies.attributes !== undefined || Dependencies.elements !== undefined) {
throw new Error('Expected Dependencies element with no child elements and no attributes.');
if (Dependencies.type !== 'element' || Dependencies.name !== 'Dependencies' || Dependencies.attributes !== undefined) {
throw new Error('Expected Dependencies element with no attributes.');
}
const hasDependencies = product.startsWith('retailclient_');
if (Dependencies.elements !== undefined && !hasDependencies) {
throw new Error('Expected Dependencies element with no child elements.');
}
if (hasDependencies) {
for (const Dependency of (Dependencies.elements as xmlJs.Element[])) {
if (Dependency.type !== 'element' || Dependency.name !== 'Dependency' || Dependency.attributes !== undefined) {
throw new Error('Expected Dependency element with no attributes.');
}
//TODO: check text nodes
}
}
//<Name>assets_swtor_de_de</Name>
@ -88,8 +100,7 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product
if (Releases.type !== 'element' || Releases.name !== 'Releases' || Releases.attributes !== undefined || Releases.elements === undefined) {
throw new Error('Expected Releases element.');
}
for (let i = 0, il = Releases.elements.length; i < il; i += 1) {
const Release = Releases.elements[i];
for (const Release of Releases.elements) {
//<Release>
if (Release.type !== 'element' || Release.name !== 'Release' || Release.attributes !== undefined || Release.elements === undefined || Release.elements.length !== 3) {
throw new Error('Expected Release element.');
@ -116,8 +127,7 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product
if (ReleaseUpdatePaths.type !== 'element' || ReleaseUpdatePaths.name !== 'ReleaseUpdatePaths' || ReleaseUpdatePaths.attributes !== undefined || ReleaseUpdatePaths.elements === undefined) {
throw new Error('Expected ReleaseUpdatePaths element.');
}
for (let i = 0, il = ReleaseUpdatePaths.elements.length; i < il; i += 1) {
const ReleaseUpdatePath = ReleaseUpdatePaths.elements[i];
for (const ReleaseUpdatePath of ReleaseUpdatePaths.elements) {
//<ReleaseUpdatePath>
if (ReleaseUpdatePath.type !== 'element' || ReleaseUpdatePath.name !== 'ReleaseUpdatePath' || ReleaseUpdatePath.attributes !== undefined || ReleaseUpdatePath.elements === undefined || ReleaseUpdatePath.elements.length !== 3) {
throw new Error('Expected ReleaseUpdatePath element.');
@ -151,10 +161,8 @@ export default function verifyPatchmanifest(manifestFile: xmlJs.Element, product
throw new Error(`Expected ExtraData element with children in patch ${fromNum}to${toNum}.`);
}
if (!isPatchWithoutExtraData) {
const ExtraDataItems = ExtraData.elements as xmlJs.Element[];
for (let j = 0, jl = ExtraDataItems.length; j < jl; j += 1) {
for (const ExtraDataItem of (ExtraData.elements as xmlJs.Element[])) {
//<ExtraDataItem>
const ExtraDataItem = ExtraDataItems[j];
if (ExtraDataItem.type !== 'element' || ExtraDataItem.name !== 'ExtraDataItem' || ExtraDataItem.attributes !== undefined || ExtraDataItem.elements === undefined || ExtraDataItem.elements.length !== 2) {
throw new Error('Expected ExtraDataItem element.');
}