From bddaef03733bae7d84dec0286efb9f9a917985bf Mon Sep 17 00:00:00 2001 From: C-3PO Date: Fri, 16 Nov 2018 00:48:36 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Split=20SsnDiffType=20inte?= =?UTF-8?q?rface=20into=20separate=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 2 +- src/interfaces/ISolidFile.ts | 4 +--- src/interfaces/ISsnFileEntry.ts | 15 ++------------- src/interfaces/SsnDiffType.ts | 12 ++++++++++++ src/ssn/extractFileAsStream.ts | 2 +- src/ssn/getPatchZip.ts | 2 +- src/ssn/installPatch.ts | 3 ++- src/ssn/reader/readSsnFile.ts | 2 +- src/ssn/verify/verifyPatch.ts | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 src/interfaces/SsnDiffType.ts diff --git a/src/index.ts b/src/index.ts index 5fc8091..78ae32c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ export { default as IManifest } from './interfaces/IManifest'; export { default as ISolidSimple } from './interfaces/ISolidSimple'; -export { ISsnFileEntry } from './interfaces/ISsnFileEntry'; +export { default as ISsnFileEntry } from './interfaces/ISsnFileEntry'; export { default as Product } from './interfaces/Product'; export { default as findReleasePath } from './ssn/findReleasePath'; export { default as getManifest } from './ssn/getManifest'; diff --git a/src/interfaces/ISolidFile.ts b/src/interfaces/ISolidFile.ts index 4c32a61..2e374e2 100644 --- a/src/interfaces/ISolidFile.ts +++ b/src/interfaces/ISolidFile.ts @@ -20,7 +20,7 @@ interface ISolidInfo { uniqueid: string; } -interface ISolid { +export default interface ISolid { /** Timestamp when this torrent was created, given in seconds since 1970. Can be read with `new Date(... * 1000)`. */ 'creation date': number; /** Internal tracker URL used to announce this torrent. */ @@ -36,5 +36,3 @@ interface ISolid { /** Contains further information about this torrent, including the list of files. */ info: ISolidInfo; } - -export default ISolid; diff --git a/src/interfaces/ISsnFileEntry.ts b/src/interfaces/ISsnFileEntry.ts index a8eadb5..18bc4e7 100644 --- a/src/interfaces/ISsnFileEntry.ts +++ b/src/interfaces/ISsnFileEntry.ts @@ -1,15 +1,6 @@ -enum SsnDiffType { - /** We included the original file contents, not just the differences, because file is new or it's in a format that's not suitable for diffing. */ - NewFile = 0, - /** File is not included in the .zip archive because it has been deleted. */ - Deleted = 1, - /** File has changed and we include the differences, encoded in vcdiff/xdelta3 */ - Changed = 2, - /** File is not included in the .zip archive because it hasn't changed */ - Unchanged = 3, -} +import SsnDiffType from './SsnDiffType'; -interface ISsnFileEntry { +export default interface ISsnFileEntry { /** CRC-32 checksum of this file. */ crc: number; /** If we only store the differences, the size of the destination file. */ @@ -33,5 +24,3 @@ interface ISsnFileEntry { /** Offset into the disk to where the local file header starts. */ offset: number; } - -export { ISsnFileEntry, SsnDiffType }; diff --git a/src/interfaces/SsnDiffType.ts b/src/interfaces/SsnDiffType.ts new file mode 100644 index 0000000..dc93ff5 --- /dev/null +++ b/src/interfaces/SsnDiffType.ts @@ -0,0 +1,12 @@ +enum SsnDiffType { + /** We included the original file contents, not just the differences, because file is new or it's in a format that's not suitable for diffing. */ + NewFile = 0, + /** File is not included in the .zip archive because it has been deleted. */ + Deleted = 1, + /** File has changed and we include the differences, encoded in vcdiff/xdelta3 */ + Changed = 2, + /** File is not included in the .zip archive because it hasn't changed */ + Unchanged = 3, +} + +export default SsnDiffType; diff --git a/src/ssn/extractFileAsStream.ts b/src/ssn/extractFileAsStream.ts index 88a00d1..b5c4e7c 100644 --- a/src/ssn/extractFileAsStream.ts +++ b/src/ssn/extractFileAsStream.ts @@ -1,6 +1,6 @@ import * as stream from 'stream'; import * as zlib from 'zlib'; -import { ISsnFileEntry } from '../interfaces/ISsnFileEntry'; +import ISsnFileEntry from '../interfaces/ISsnFileEntry'; import decryptTransform from './streams/decryptTransform'; import readBytesFromStream from './streams/readBytesFromStream'; diff --git a/src/ssn/getPatchZip.ts b/src/ssn/getPatchZip.ts index 395db30..6534f58 100644 --- a/src/ssn/getPatchZip.ts +++ b/src/ssn/getPatchZip.ts @@ -1,5 +1,5 @@ import getUrlContents from '../cdn/getUrlContents'; -import { ISsnFileEntry } from '../interfaces/ISsnFileEntry'; +import ISsnFileEntry from '../interfaces/ISsnFileEntry'; import Product from '../interfaces/Product'; import getSolidpkg from './getSolidpkg'; import readSsnFile from './reader/readSsnFile'; diff --git a/src/ssn/installPatch.ts b/src/ssn/installPatch.ts index 2469020..0075ad6 100644 --- a/src/ssn/installPatch.ts +++ b/src/ssn/installPatch.ts @@ -3,8 +3,9 @@ import * as path from 'path'; import downloadWrapper from '../cdn/downloadWrapper'; import createDirRecursively from '../cdn/funcs/createDirRecursively'; import getUrlContents from '../cdn/getUrlContents'; -import { ISsnFileEntry, SsnDiffType } from '../interfaces/ISsnFileEntry'; +import ISsnFileEntry from '../interfaces/ISsnFileEntry'; import Product from '../interfaces/Product'; +import SsnDiffType from '../interfaces/SsnDiffType'; import getSolidpkg from './getSolidpkg'; import launch from './installation/launch'; import taskManager from './installation/taskManager'; diff --git a/src/ssn/reader/readSsnFile.ts b/src/ssn/reader/readSsnFile.ts index 3c488a9..ea7de28 100644 --- a/src/ssn/reader/readSsnFile.ts +++ b/src/ssn/reader/readSsnFile.ts @@ -3,7 +3,7 @@ * Check the .ZIP File Format Specification . */ -import { ISsnFileEntry } from '../../interfaces/ISsnFileEntry'; +import ISsnFileEntry from '../../interfaces/ISsnFileEntry'; import getDecryptionKeys from '../decryption/getDecryptionKeys'; import modifyPassword from '../decryption/modifyPassword'; diff --git a/src/ssn/verify/verifyPatch.ts b/src/ssn/verify/verifyPatch.ts index e8382bc..2ec1513 100644 --- a/src/ssn/verify/verifyPatch.ts +++ b/src/ssn/verify/verifyPatch.ts @@ -1,6 +1,6 @@ -import { ISsnFileEntry } from '../../interfaces/ISsnFileEntry'; -import { SsnDiffType } from '../../interfaces/ISsnFileEntry'; +import ISsnFileEntry from '../../interfaces/ISsnFileEntry'; import Product from '../../interfaces/Product'; +import SsnDiffType from '../../interfaces/SsnDiffType'; /** Receives a list of file entries from the .zip file and checks them for correctness */ export default function verifyPatch(fileEntries: ISsnFileEntry[], product: Product, from: number): void {