From ee3fd0a60f74a8511eae54fd3721fd4cb03ffdc0 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Fri, 22 Jun 2018 17:59:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A1=20Update=20comments=20for=20releas?= =?UTF-8?q?e=20path=20search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{ => cdn}/getUrlContents.ts | 0 src/ssn/getPatchmanifest.ts | 2 +- src/ssn/getSolidpkg.ts | 2 +- src/ssn/releasePaths.ts | 26 +++++++++++++++++++------- 4 files changed, 21 insertions(+), 9 deletions(-) rename src/{ => cdn}/getUrlContents.ts (100%) diff --git a/src/getUrlContents.ts b/src/cdn/getUrlContents.ts similarity index 100% rename from src/getUrlContents.ts rename to src/cdn/getUrlContents.ts diff --git a/src/ssn/getPatchmanifest.ts b/src/ssn/getPatchmanifest.ts index a60f31b..d0c231e 100644 --- a/src/ssn/getPatchmanifest.ts +++ b/src/ssn/getPatchmanifest.ts @@ -1,5 +1,5 @@ import { TextDecoder } from 'util'; -import getUrlContents from '../getUrlContents'; +import getUrlContents from '../cdn/getUrlContents'; import { Product } from '../interfaces/ISettings'; import verifyProductName from '../ssn/verifyProductName'; import extractFile from './extractFile'; diff --git a/src/ssn/getSolidpkg.ts b/src/ssn/getSolidpkg.ts index 75f536b..5aa4781 100644 --- a/src/ssn/getSolidpkg.ts +++ b/src/ssn/getSolidpkg.ts @@ -1,4 +1,4 @@ -import getUrlContents from '../getUrlContents'; +import getUrlContents from '../cdn/getUrlContents'; import { Product } from '../interfaces/ISettings'; import ISolid from '../interfaces/ISolidFile'; import verifyProductName from '../ssn/verifyProductName'; diff --git a/src/ssn/releasePaths.ts b/src/ssn/releasePaths.ts index 9870d98..587d0e2 100644 --- a/src/ssn/releasePaths.ts +++ b/src/ssn/releasePaths.ts @@ -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 if (product.startsWith('patcher')) { return [-1]; } else { const froms: number[] = []; - //always X-1toX + //Always X-1toX 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 % 5) === 0) { - //also X-5toX if X % 5 + //Also X-5toX if X % 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); } - //also downgrade from the following four releases + //Also downgrade from the following four releases froms.push(releaseTo + 1); froms.push(releaseTo + 2); froms.push(releaseTo + 3); 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: 5to7, 5to8, 5to9, @@ -38,3 +39,14 @@ export default function getFroms(product: string, releaseTo: number) { 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]] +}