diff --git a/src/interfaces/ISsnFileEntry.ts b/src/interfaces/ISsnFileEntry.ts index 533e1f6..ef431e4 100644 --- a/src/interfaces/ISsnFileEntry.ts +++ b/src/interfaces/ISsnFileEntry.ts @@ -34,4 +34,4 @@ interface ISsnFileEntry { offset: number; } -export default ISsnFileEntry; +export { ISsnFileEntry, SsnDiffType }; diff --git a/src/ssn/getPatch.ts b/src/ssn/getPatch.ts index 29ba3ff..8c7ee11 100644 --- a/src/ssn/getPatch.ts +++ b/src/ssn/getPatch.ts @@ -1,5 +1,6 @@ import getUrlContents from '../cdn/getUrlContents'; import { Product } from '../interfaces/ISettings'; +import { SsnDiffType } from '../interfaces/ISsnFileEntry'; import extractFile from './extractFile'; import getSolidpkg from './getSolidpkg'; import readSsnFile from './readSsnFile'; @@ -9,13 +10,29 @@ export default async function getPatch(product: Product, from: number, to: numbe const bufferArray = await Promise.all(solidPkg.files.map((file) => getUrlContents({ host: 'cdn-patch.swtor.com', path: `/patch/${product}/${product}_${from}to${to}/${file.name}` }))); const zipFile = bufferArray[bufferArray.length - 1]; + const dvArray = bufferArray.map((buffer) => new DataView(buffer)); const fileEntries = readSsnFile(zipFile); //TODO: verify file entries + console.log(fileEntries); - const dvArray = bufferArray.map((buffer) => new DataView(buffer)); - fileEntries.map((entry) => extractFile(entry, dvArray) ); + //Extract newly added files + fileEntries.filter((file) => file.diffType === SsnDiffType.NewFile).forEach(async (file) => { + const fileContents = await extractFile(file, dvArray); + console.log(fileContents); + //TODO + }); - return fileEntries; + //Extract changed files + fileEntries.filter((file) => file.diffType === SsnDiffType.Changed).forEach((file) => { + const fileContents = await extractFile(file, dvArray); + console.log(fileContents); + //TODO + }); + + //Need to delete deleted files + fileEntries.filter((file) => file.diffType === SsnDiffType.Deleted).forEach((file) => { + //TODO + }); }