🐛 Fix patcher to ignore unchanged & deleted files

This commit is contained in:
C-3PO 2018-06-23 22:39:34 +02:00
parent 6e292106e3
commit a416d86dbe
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
2 changed files with 21 additions and 4 deletions

View file

@ -34,4 +34,4 @@ interface ISsnFileEntry {
offset: number;
}
export default ISsnFileEntry;
export { ISsnFileEntry, SsnDiffType };

View file

@ -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
});
}