💡 Update comments for release path search
This commit is contained in:
parent
07caf282d8
commit
ee3fd0a60f
4 changed files with 21 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { TextDecoder } from 'util';
|
import { TextDecoder } from 'util';
|
||||||
import getUrlContents from '../getUrlContents';
|
import getUrlContents from '../cdn/getUrlContents';
|
||||||
import { Product } from '../interfaces/ISettings';
|
import { Product } from '../interfaces/ISettings';
|
||||||
import verifyProductName from '../ssn/verifyProductName';
|
import verifyProductName from '../ssn/verifyProductName';
|
||||||
import extractFile from './extractFile';
|
import extractFile from './extractFile';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import getUrlContents from '../getUrlContents';
|
import getUrlContents from '../cdn/getUrlContents';
|
||||||
import { Product } from '../interfaces/ISettings';
|
import { Product } from '../interfaces/ISettings';
|
||||||
import ISolid from '../interfaces/ISolidFile';
|
import ISolid from '../interfaces/ISolidFile';
|
||||||
import verifyProductName from '../ssn/verifyProductName';
|
import verifyProductName from '../ssn/verifyProductName';
|
||||||
|
|
|
@ -1,27 +1,28 @@
|
||||||
export default function getFroms(product: string, releaseTo: number) {
|
/** For the given release in the given product, returns from which releases we can patch to this release. */
|
||||||
|
function getFroms({ product, to: releaseTo}: {product: string, to: number}) {
|
||||||
//The launcher (patcher, patcher2014, patcher2017) is always installing from -1, never from a previous version
|
//The launcher (patcher, patcher2014, patcher2017) is always installing from -1, never from a previous version
|
||||||
if (product.startsWith('patcher')) {
|
if (product.startsWith('patcher')) {
|
||||||
return [-1];
|
return [-1];
|
||||||
} else {
|
} else {
|
||||||
const froms: number[] = [];
|
const froms: number[] = [];
|
||||||
|
|
||||||
//always X-1toX
|
//Always X-1toX
|
||||||
froms.push(releaseTo - 1);
|
froms.push(releaseTo - 1);
|
||||||
|
|
||||||
//also 0toX, unless X is 0
|
//Also 0toX, unless X is 0. And no need to add 0to1 a second time.
|
||||||
if (releaseTo >= 2) { froms.push(0); }
|
if (releaseTo >= 2) { froms.push(0); }
|
||||||
|
|
||||||
if ((releaseTo % 5) === 0) {
|
if ((releaseTo % 5) === 0) {
|
||||||
//also X-5toX if X % 5
|
//Also X-5toX if X % 5
|
||||||
if (releaseTo >= 10) { froms.push(releaseTo - 5); }
|
if (releaseTo >= 10) { froms.push(releaseTo - 5); }
|
||||||
//also X-20toX if X % 5
|
//Also X-20toX if X % 5
|
||||||
if (releaseTo >= 25) { froms.push(releaseTo - 20); }
|
if (releaseTo >= 25) { froms.push(releaseTo - 20); }
|
||||||
//also downgrade from the following four releases
|
//Also downgrade from the following four releases
|
||||||
froms.push(releaseTo + 1);
|
froms.push(releaseTo + 1);
|
||||||
froms.push(releaseTo + 2);
|
froms.push(releaseTo + 2);
|
||||||
froms.push(releaseTo + 3);
|
froms.push(releaseTo + 3);
|
||||||
froms.push(releaseTo + 4);
|
froms.push(releaseTo + 4);
|
||||||
} else { //for some of the older releases, an update from _5 or _0 is possible
|
} else { //For some of the older releases, an update from _5 or _0 is possible
|
||||||
/*
|
/*
|
||||||
e.g. in asset_swtor_main:
|
e.g. in asset_swtor_main:
|
||||||
5to7, 5to8, 5to9,
|
5to7, 5to8, 5to9,
|
||||||
|
@ -38,3 +39,14 @@ export default function getFroms(product: string, releaseTo: number) {
|
||||||
return froms;
|
return froms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Checks whether there is a valid path between our current release and the release we want to update to, and returns true or false.
|
||||||
|
* Does not actually look at the manifest.xml file but theorizes on possible patches based on the usually created patches, allowing
|
||||||
|
* us to find release pathes for products that have not been released yet.
|
||||||
|
*/
|
||||||
|
export default function findReleasePath({ product, from, to}: {product: string, from: number, to: number}) {
|
||||||
|
//TODO: need to recursively get froms until path is found
|
||||||
|
//TODO: need to ignore patches that we know are bugged (i.e. missing from CDN)
|
||||||
|
return getFroms({ product, to }).includes(from);
|
||||||
|
//TODO: we also need to return the release path, e.g. [[3, 4], [4, 5], [5, 6]]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue