MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / parseUpgradeStage

Function parseUpgradeStage

src/renderer/upgrade/UpgradeFile.ts:41–67  ·  view source on GitHub ↗
(parser: IObjectParserProp<any>, key: string, onError?: (error: string) => void)

Source from the content-addressed store, hash-verified

39 }
40
41 function parseUpgradeStage(parser: IObjectParserProp<any>, key: string, onError?: (error: string) => void): UpgradeStage {
42 const parsed: UpgradeStage = {
43 id: uuid(),
44 title: '',
45 description: '',
46 verify_files: [],
47 verify_sha256: [],
48 sources: [],
49 sources_sha256: '',
50 deletePaths: [],
51 keepPaths: [],
52 state: newUpgradeStageState()
53 };
54 parser.prop('title', v => parsed.title = str(v));
55 parser.prop('description', v => parsed.description = str(v));
56 parser.prop('verify_files', v => parsed.verify_files = strArr(v));
57 parser.prop('verify_sha256', v => parsed.verify_sha256 = strArr(v), true);
58 parser.prop('sources', v => parsed.sources = strArr(v));
59 parser.prop('sources_sha256', v => parsed.sources_sha256 = str(v), true);
60 parser.prop('deletePaths', v => parsed.deletePaths = strArr(v), true);
61 parser.prop('keepPaths', v => parsed.keepPaths = strArr(v), true);
62 if (parsed.sources_sha256.length !== 64 && onError) {
63 // All SHA256 sums are 64 characters long
64 onError(`IMPORTANT: No valid SHA256 sum given, risk of corrupted or malicious downloads. (stack: "${key}")`);
65 }
66 return parsed;
67 }
68}
69
70function newUpgradeStageState(): UpgradeStageState {

Callers 1

parseFileFunction · 0.85

Calls 6

uuidFunction · 0.90
newUpgradeStageStateFunction · 0.85
strFunction · 0.85
strArrFunction · 0.85
propMethod · 0.65
onErrorFunction · 0.50

Tested by

no test coverage detected