From 88425a79c34d1147713ffd6c4251961dedf65df5 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 22 Feb 2021 00:50:21 -0500 Subject: [PATCH] Add check for existing assets --- src/converters/effect/EffectConverter.ts | 2 +- src/converters/effect/EffectDownloader.ts | 7 ++++++- src/converters/figure/FigureConverter.ts | 2 +- src/converters/figure/FigureDownloader.ts | 7 ++++++- src/converters/furniture/FurnitureConverter.ts | 2 +- src/converters/furniture/FurnitureDownloader.ts | 11 ++++++++++- src/converters/pet/PetConverter.ts | 2 +- src/converters/pet/PetDownloader.ts | 7 ++++++- 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/converters/effect/EffectConverter.ts b/src/converters/effect/EffectConverter.ts index a916147..9de51d1 100644 --- a/src/converters/effect/EffectConverter.ts +++ b/src/converters/effect/EffectConverter.ts @@ -34,7 +34,7 @@ export class EffectConverter extends SWFConverter try { - await this._effectDownloader.download(async (habboAssetSwf: HabboAssetSWF, className: string) => + await this._effectDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF, className: string) => { spinner.text = 'Parsing Effect: ' + habboAssetSwf.getDocumentClass(); diff --git a/src/converters/effect/EffectDownloader.ts b/src/converters/effect/EffectDownloader.ts index e7651df..de38157 100644 --- a/src/converters/effect/EffectDownloader.ts +++ b/src/converters/effect/EffectDownloader.ts @@ -2,6 +2,7 @@ import { singleton } from 'tsyringe'; import { Configuration } from '../../common/config/Configuration'; import { IEffectMap } from '../../mapping/json'; import { HabboAssetSWF } from '../../swf/HabboAssetSWF'; +import File from '../../utils/File'; import { FileUtilities } from '../../utils/FileUtilities'; import { Logger } from '../../utils/Logger'; @@ -15,7 +16,7 @@ export class EffectDownloader private readonly _logger: Logger) {} - public async download(callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise + public async download(directory: File, callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise { const effectMap = await this.parseEffectMap(); const classNames: string[] = []; @@ -26,6 +27,10 @@ export class EffectDownloader { const className = library.lib; + const existingFile = new File(directory.path + '/' + className + '.nitro'); + + if(existingFile.isDirectory) continue; + if(classNames.indexOf(className) >= 0) continue; classNames.push(className); diff --git a/src/converters/figure/FigureConverter.ts b/src/converters/figure/FigureConverter.ts index 2cda8b2..84e65a5 100644 --- a/src/converters/figure/FigureConverter.ts +++ b/src/converters/figure/FigureConverter.ts @@ -34,7 +34,7 @@ export class FigureConverter extends SWFConverter try { - await this._figureDownloader.download(async (habboAssetSwf: HabboAssetSWF, className: string) => + await this._figureDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF, className: string) => { spinner.text = 'Parsing Figure: ' + habboAssetSwf.getDocumentClass(); diff --git a/src/converters/figure/FigureDownloader.ts b/src/converters/figure/FigureDownloader.ts index 1876614..b359039 100644 --- a/src/converters/figure/FigureDownloader.ts +++ b/src/converters/figure/FigureDownloader.ts @@ -2,6 +2,7 @@ import { singleton } from 'tsyringe'; import { Configuration } from '../../common/config/Configuration'; import { IFigureMap } from '../../mapping/json'; import { HabboAssetSWF } from '../../swf/HabboAssetSWF'; +import File from '../../utils/File'; import { FileUtilities } from '../../utils/FileUtilities'; import { Logger } from '../../utils/Logger'; @@ -15,7 +16,7 @@ export class FigureDownloader private readonly _logger: Logger) {} - public async download(callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise + public async download(directory: File, callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise { const figureMap = await this.parseFigureMap(); const classNames: string[] = []; @@ -26,6 +27,10 @@ export class FigureDownloader { const className = library.id.split('*')[0]; + const existingFile = new File(directory.path + '/' + className + '.nitro'); + + if(existingFile.isDirectory) continue; + if(className === 'hh_human_fx' || className === 'hh_pets') continue; if(classNames.indexOf(className) >= 0) continue; diff --git a/src/converters/furniture/FurnitureConverter.ts b/src/converters/furniture/FurnitureConverter.ts index 1ee9647..de4e1aa 100644 --- a/src/converters/furniture/FurnitureConverter.ts +++ b/src/converters/furniture/FurnitureConverter.ts @@ -34,7 +34,7 @@ export class FurnitureConverter extends SWFConverter try { - await this._furniDownloader.download(async (habboAssetSwf: HabboAssetSWF) => + await this._furniDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF) => { spinner.text = 'Parsing Furniture: ' + habboAssetSwf.getDocumentClass(); diff --git a/src/converters/furniture/FurnitureDownloader.ts b/src/converters/furniture/FurnitureDownloader.ts index b448cf5..d8cefbd 100644 --- a/src/converters/furniture/FurnitureDownloader.ts +++ b/src/converters/furniture/FurnitureDownloader.ts @@ -2,6 +2,7 @@ import { singleton } from 'tsyringe'; import { Configuration } from '../../common/config/Configuration'; import { IFurnitureData } from '../../mapping/json'; import { HabboAssetSWF } from '../../swf/HabboAssetSWF'; +import File from '../../utils/File'; import { FileUtilities } from '../../utils/FileUtilities'; import { Logger } from '../../utils/Logger'; @@ -13,7 +14,7 @@ export class FurnitureDownloader private readonly _logger: Logger) {} - public async download(callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise + public async download(directory: File, callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise { const furniData = await this.parseFurniData(); @@ -30,6 +31,10 @@ export class FurnitureDownloader const className = furniType.classname.split('*')[0]; const revision = furniType.revision; + const existingFile = new File(directory.path + '/' + className + '.nitro'); + + if(existingFile.isDirectory) continue; + if(classNames.indexOf(className) >= 0) continue; classNames.push(className); @@ -57,6 +62,10 @@ export class FurnitureDownloader const className = furniType.classname.split('*')[0]; const revision = furniType.revision; + const existingFile = new File(directory.path + '/' + className + '.nitro'); + + if(existingFile.isDirectory) continue; + if(classNames.indexOf(className) >= 0) continue; classNames.push(className); diff --git a/src/converters/pet/PetConverter.ts b/src/converters/pet/PetConverter.ts index 4bdbfd8..538fae7 100644 --- a/src/converters/pet/PetConverter.ts +++ b/src/converters/pet/PetConverter.ts @@ -34,7 +34,7 @@ export class PetConverter extends SWFConverter try { - await this._petDownloader.download(async (habboAssetSwf: HabboAssetSWF) => + await this._petDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF) => { spinner.text = 'Parsing Pet: ' + habboAssetSwf.getDocumentClass(); diff --git a/src/converters/pet/PetDownloader.ts b/src/converters/pet/PetDownloader.ts index c1a174b..5ee422f 100644 --- a/src/converters/pet/PetDownloader.ts +++ b/src/converters/pet/PetDownloader.ts @@ -1,6 +1,7 @@ import { singleton } from 'tsyringe'; import { Configuration } from '../../common/config/Configuration'; import { HabboAssetSWF } from '../../swf/HabboAssetSWF'; +import File from '../../utils/File'; import { FileUtilities } from '../../utils/FileUtilities'; import { Logger } from '../../utils/Logger'; @@ -12,7 +13,7 @@ export class PetDownloader private readonly _logger: Logger) {} - public async download(callback: (habboAssetSwf: HabboAssetSWF) => Promise): Promise + public async download(directory: File, callback: (habboAssetSwf: HabboAssetSWF) => Promise): Promise { const petTypes = await this.parsePetTypes(); @@ -22,6 +23,10 @@ export class PetDownloader for(const petType of petTypes) { + const existingFile = new File(directory.path + '/' + petType + '.nitro'); + + if(existingFile.isDirectory) continue; + if(classNames.indexOf(petType) >= 0) continue; classNames.push(petType);