mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-22 06:49:05 -04:00
Streamline the fingerprinting process
This commit is contained in:
@@ -221,9 +221,7 @@ export class CurseAddonProvider extends AddonProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
console.time("CFScan");
|
||||
const scanResults = await this.getScanResults(addonFolders);
|
||||
console.timeEnd("CFScan");
|
||||
const scanResults = this.getScanResults(addonFolders);
|
||||
|
||||
await this.mapAddonFolders(scanResults, installation);
|
||||
|
||||
@@ -265,12 +263,8 @@ export class CurseAddonProvider extends AddonProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public getScanResults = async (addonFolders: AddonFolder[]): Promise<AppCurseScanResult[]> => {
|
||||
const filePaths = addonFolders.map((addonFolder) => addonFolder.path);
|
||||
const scanResults: CurseFolderScanResult[] = await this._electronService.invoke(
|
||||
IPC_CURSE_GET_SCAN_RESULTS,
|
||||
filePaths
|
||||
);
|
||||
public getScanResults = (addonFolders: AddonFolder[]): AppCurseScanResult[] => {
|
||||
const scanResults = addonFolders.map((af) => af.cfScanResults).filter((sr) => sr !== undefined);
|
||||
|
||||
const appScanResults: AppCurseScanResult[] = scanResults.map((scanResult) => {
|
||||
const addonFolder = addonFolders.find((af) => af.path === scanResult.directory);
|
||||
|
||||
@@ -234,9 +234,7 @@ export class CurseAddonV2Provider extends AddonProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
console.time("CFScan");
|
||||
const scanResults = await this.getScanResults(addonFolders);
|
||||
console.timeEnd("CFScan");
|
||||
const scanResults = this.getScanResults(addonFolders);
|
||||
|
||||
await this.mapAddonFolders(scanResults, installation);
|
||||
|
||||
@@ -278,12 +276,8 @@ export class CurseAddonV2Provider extends AddonProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public getScanResults = async (addonFolders: AddonFolder[]): Promise<AppCurseV2ScanResult[]> => {
|
||||
const filePaths = addonFolders.map((addonFolder) => addonFolder.path);
|
||||
const scanResults: CurseFolderScanResult[] = await this._electronService.invoke(
|
||||
IPC_CURSE_GET_SCAN_RESULTS,
|
||||
filePaths
|
||||
);
|
||||
public getScanResults = (addonFolders: AddonFolder[]): AppCurseV2ScanResult[] => {
|
||||
const scanResults = addonFolders.map((af) => af.cfScanResults).filter((sr) => sr !== undefined);
|
||||
|
||||
const appScanResults: AppCurseV2ScanResult[] = scanResults.map((scanResult) => {
|
||||
const addonFolder = addonFolders.find((af) => af.path === scanResult.directory);
|
||||
|
||||
@@ -208,7 +208,7 @@ export class WagoAddonProvider extends AddonProvider {
|
||||
}
|
||||
|
||||
const gameVersion = this.getGameVersion(installation.clientType);
|
||||
const scanResults = await this.getScanResults(addonFolders);
|
||||
const scanResults = addonFolders.map((af) => af.wowUpScanResults).filter((sr) => sr !== undefined);
|
||||
|
||||
const request: WagoFingerprintRequest = {
|
||||
game_version: gameVersion,
|
||||
|
||||
@@ -249,9 +249,7 @@ export class WowUpAddonProvider extends AddonProvider {
|
||||
): Promise<void> {
|
||||
const gameType = this.getWowGameType(installation.clientType);
|
||||
|
||||
console.time("WowUpScan");
|
||||
const scanResults = await this.getScanResults(addonFolders);
|
||||
console.timeEnd("WowUpScan");
|
||||
const scanResults = addonFolders.map((af) => af.wowUpScanResults).filter((sr) => sr !== undefined);
|
||||
|
||||
const fingerprints = scanResults.map((result) => result.fingerprint);
|
||||
console.log("[WowUpFingerprints]", JSON.stringify(fingerprints));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { FsStats } from "../../../common/models/ipc-events";
|
||||
import { Addon } from "../../../common/entities/addon";
|
||||
import { Toc } from "./toc";
|
||||
import { CurseFolderScanResult } from "../../../common/curse/curse-folder-scan-result";
|
||||
import { AppWowUpScanResult } from "./app-wowup-scan-result";
|
||||
|
||||
export interface AddonFolder {
|
||||
name: string;
|
||||
@@ -12,4 +14,6 @@ export interface AddonFolder {
|
||||
tocs: Toc[];
|
||||
matchingAddon?: Addon;
|
||||
fileStats?: FsStats;
|
||||
cfScanResults?: CurseFolderScanResult;
|
||||
wowUpScanResults?: AppWowUpScanResult;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { IPC_CURSE_GET_SCAN_RESULTS, IPC_WOWUP_GET_SCAN_RESULTS } from "../../../common/constants";
|
||||
import { CurseFolderScanResult } from "../../../common/curse/curse-folder-scan-result";
|
||||
import { AddonFolder } from "../../models/wowup/addon-folder";
|
||||
import { AppWowUpScanResult } from "../../models/wowup/app-wowup-scan-result";
|
||||
import { ElectronService } from "../electron/electron.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class AddonFingerprintService {
|
||||
constructor(private _electronService: ElectronService) {}
|
||||
|
||||
async getFingerprints(addonFolders: AddonFolder[]) {
|
||||
const filePaths = addonFolders.map((addonFolder) => addonFolder.path);
|
||||
|
||||
console.time("WowUpScan");
|
||||
const wowUpScanResults: AppWowUpScanResult[] = await this._electronService.invoke(
|
||||
IPC_WOWUP_GET_SCAN_RESULTS,
|
||||
filePaths
|
||||
);
|
||||
console.timeEnd("WowUpScan");
|
||||
|
||||
console.time("CFScan");
|
||||
const cfScanResults: CurseFolderScanResult[] = await this._electronService.invoke(
|
||||
IPC_CURSE_GET_SCAN_RESULTS,
|
||||
filePaths
|
||||
);
|
||||
console.timeEnd("CFScan");
|
||||
|
||||
addonFolders.forEach((af) => {
|
||||
af.wowUpScanResults = wowUpScanResults.find((wur) => wur.path === af.path);
|
||||
af.cfScanResults = cfScanResults.find((cfr) => cfr.directory === af.path);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ import { WarcraftService } from "../warcraft/warcraft.service";
|
||||
import { WowUpService } from "../wowup/wowup.service";
|
||||
import { AddonProviderFactory } from "./addon.provider.factory";
|
||||
import { CurseAddonV2Provider } from "../../addon-providers/curse-addon-v2-provider";
|
||||
import { AddonFingerprintService } from "./addon-fingerprint.service";
|
||||
|
||||
export enum ScanUpdateType {
|
||||
Start,
|
||||
@@ -141,7 +142,8 @@ export class AddonService {
|
||||
private _fileService: FileService,
|
||||
private _tocService: TocService,
|
||||
private _warcraftInstallationService: WarcraftInstallationService,
|
||||
private _addonProviderService: AddonProviderFactory
|
||||
private _addonProviderService: AddonProviderFactory,
|
||||
private _addonFingerprintService: AddonFingerprintService
|
||||
) {
|
||||
// This should keep the current update queue state snapshot up to date
|
||||
const addonInstalledSub = this.addonInstalled$
|
||||
@@ -1534,6 +1536,9 @@ export class AddonService {
|
||||
|
||||
await this.removeGitFolders(addonFolders);
|
||||
|
||||
// Get all the fingerprints we might need
|
||||
await this._addonFingerprintService.getFingerprints(addonFolders);
|
||||
|
||||
this._scanUpdateSrc.next({
|
||||
type: ScanUpdateType.Update,
|
||||
currentCount: 0,
|
||||
@@ -1544,6 +1549,7 @@ export class AddonService {
|
||||
for (const provider of enabledProviders) {
|
||||
try {
|
||||
const validFolders = addonFolders.filter((af) => !af.ignoreReason && !af.matchingAddon && af.tocs.length > 0);
|
||||
|
||||
await provider.scan(installation, defaultAddonChannel, validFolders);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
Reference in New Issue
Block a user