Use std scan result

This commit is contained in:
jliddev
2022-11-18 10:45:48 -06:00
parent 00605565fd
commit b4449eaacb
5 changed files with 16 additions and 22 deletions

View File

@@ -85,7 +85,7 @@ import { DownloadStatusType } from "../src/common/models/download-status-type";
import { FsDirent, TreeNode } from "../src/common/models/ipc-events";
import { UnzipRequest } from "../src/common/models/unzip-request";
import { RendererChannels } from "../src/common/wowup";
import { MenuConfig, SystemTrayConfig, WowUpScanResult } from "../src/common/wowup/models";
import { MenuConfig, SystemTrayConfig } from "../src/common/wowup/models";
import { createAppMenu } from "./app-menu";
import * as fsp from "fs/promises";
@@ -109,7 +109,7 @@ import { GetDirectoryTreeRequest } from "../src/common/models/ipc-request";
import { ProductDb } from "../src/common/wowup/product-db";
import { restoreWindow } from "./window-state";
import { firstValueFrom, from, mergeMap, toArray } from "rxjs";
import { Addon, FsStats } from "wowup-lib-core";
import { Addon, AddonScanResult, FsStats } from "wowup-lib-core";
let PENDING_OPEN_URLS: string[] = [];
@@ -367,7 +367,7 @@ export function initializeIpcHandlers(window: BrowserWindow): void {
return true;
});
handle(IPC_WOWUP_GET_SCAN_RESULTS, async (evt, filePaths: string[]): Promise<WowUpScanResult[]> => {
handle(IPC_WOWUP_GET_SCAN_RESULTS, async (evt, filePaths: string[]): Promise<AddonScanResult[]> => {
const taskResults = await firstValueFrom(
from(filePaths).pipe(
mergeMap((folder) => from(new WowUpFolderScanner(folder).scanFolder()), 3),

View File

@@ -1,10 +1,10 @@
import * as _ from "lodash";
import * as path from "path";
import * as log from "electron-log";
import { WowUpScanResult } from "../src/common/wowup/models";
import { exists, readDirRecursive, hashFile, hashString } from "./file.utils";
import * as fsp from "fs/promises";
import { firstValueFrom, from, mergeMap, toArray } from "rxjs";
import { AddonScanResult } from "wowup-lib-core";
const INVALID_PATH_CHARS = [
"|",
@@ -75,7 +75,7 @@ export class WowUpFolderScanner {
return /<!--.*?-->/gis;
}
public async scanFolder(): Promise<WowUpScanResult> {
public async scanFolder(): Promise<AddonScanResult> {
const files = await readDirRecursive(this._folderPath);
files.forEach((fp) => (this._fileMap[fp.toLowerCase()] = fp));
@@ -97,9 +97,11 @@ export class WowUpFolderScanner {
const hashConcat = _.orderBy(fingerprintList).join("");
const fingerprint = hashString(hashConcat);
const result: WowUpScanResult = {
const result: AddonScanResult = {
source: 'wowup',
fileFingerprints: fingerprintList,
fingerprint,
fingerprintNum: 0,
path: this._folderPath,
folderName: path.basename(this._folderPath),
fileCount: matchingFiles.length,

View File

@@ -24,7 +24,7 @@
"pushy-electron": "1.0.10",
"rxjs": "7.5.6",
"win-ca": "3.5.0",
"wowup-lib-core": "0.0.1",
"wowup-lib-core": "0.0.3",
"yauzl": "2.10.0"
},
"devDependencies": {
@@ -23236,9 +23236,9 @@
"license": "Apache-2.0"
},
"node_modules/wowup-lib-core": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/wowup-lib-core/-/wowup-lib-core-0.0.1.tgz",
"integrity": "sha512-1ECaJcFzDG/yNzi6YFBTBuax/IbHYnXeedlufqVxKrdF0YtW1aeYyLZLFLPb9zwjuCggcMkof+2wNtm+2mD1+A=="
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/wowup-lib-core/-/wowup-lib-core-0.0.3.tgz",
"integrity": "sha512-4DiOLh7L88KPYIBnIdGOAcjzED/LdTuia0/FL0wwuyapYOrvOHXKnqtBQ/NmBjZP/7LxVxzvStzUH4e+H+CluA=="
},
"node_modules/wrap-ansi": {
"version": "7.0.0",
@@ -38498,9 +38498,9 @@
"dev": true
},
"wowup-lib-core": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/wowup-lib-core/-/wowup-lib-core-0.0.1.tgz",
"integrity": "sha512-1ECaJcFzDG/yNzi6YFBTBuax/IbHYnXeedlufqVxKrdF0YtW1aeYyLZLFLPb9zwjuCggcMkof+2wNtm+2mD1+A=="
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/wowup-lib-core/-/wowup-lib-core-0.0.3.tgz",
"integrity": "sha512-4DiOLh7L88KPYIBnIdGOAcjzED/LdTuia0/FL0wwuyapYOrvOHXKnqtBQ/NmBjZP/7LxVxzvStzUH4e+H+CluA=="
},
"wrap-ansi": {
"version": "7.0.0",

View File

@@ -70,7 +70,7 @@
"pushy-electron": "1.0.10",
"rxjs": "7.5.6",
"win-ca": "3.5.0",
"wowup-lib-core": "0.0.1",
"wowup-lib-core": "0.0.3",
"yauzl": "2.10.0"
},
"devDependencies": {

View File

@@ -53,14 +53,6 @@ export interface SystemTrayConfig {
checkUpdateLabel: string;
}
export interface WowUpScanResult {
fileCount: number;
fileFingerprints: string[];
fingerprint: string;
folderName: string;
path: string;
}
export type PushAction = "addon-update";
export interface PushNotification<T extends PushNotificationData | string> {