🪚 Wiring up extractComicCover call with UI

This commit is contained in:
2021-05-05 18:01:54 -07:00
parent 2abd46c18c
commit 625554808a
2 changed files with 12 additions and 14 deletions

View File

@@ -1,9 +1,9 @@
import axios from "axios"; import axios from "axios";
import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
import { import {
IExtractComicBookCoverErrorResponse, IExtractComicBookCoverErrorResponse,
IExtractedComicBookCoverFile, IExtractedComicBookCoverFile,
IExtractionOptions, IExtractionOptions,
IFolderData,
} from "../../server/interfaces/folder.interface"; } from "../../server/interfaces/folder.interface";
import { FS_API_BASE_URI } from "../constants/endpoints"; import { FS_API_BASE_URI } from "../constants/endpoints";
@@ -25,6 +25,7 @@ export async function walkFolder(path: string): Promise<Array<IFolderData>> {
export async function extractCoverFromComicBookArchive( export async function extractCoverFromComicBookArchive(
options: IExtractionOptions, options: IExtractionOptions,
walkedFolders: Array<IFolderData>,
): Promise< ): Promise<
| IExtractedComicBookCoverFile | IExtractedComicBookCoverFile
| IExtractedComicBookCoverFile[] | IExtractedComicBookCoverFile[]
@@ -34,7 +35,8 @@ export async function extractCoverFromComicBookArchive(
url: FS_API_BASE_URI + "getComicCovers", url: FS_API_BASE_URI + "getComicCovers",
method: "POST", method: "POST",
data: { data: {
...options, options,
walkedFolders,
}, },
}); });
} }

View File

@@ -2,9 +2,7 @@ import {
walkFolder, walkFolder,
extractCoverFromComicBookArchive, extractCoverFromComicBookArchive,
} from "../actions/fileops.actions"; } from "../actions/fileops.actions";
import { SUPPORTED_COMIC_ARCHIVES } from "../constants/importer.config";
import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface"; import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface";
import _ from "lodash";
export const greet = async ( export const greet = async (
path: string, path: string,
@@ -13,6 +11,7 @@ export const greet = async (
sourceFolder: path, sourceFolder: path,
extractTarget: "all", extractTarget: "all",
targetExtractionFolder: "./userdata/expanded", targetExtractionFolder: "./userdata/expanded",
extractionMode: "bulk",
}; };
const pagingConfig = { const pagingConfig = {
@@ -21,14 +20,11 @@ export const greet = async (
}; };
const fileObjects = await walkFolder("./comics"); const fileObjects = await walkFolder("./comics");
return await extractCoverFromComicBookArchive(
{ {
if (SUPPORTED_COMIC_ARCHIVES.includes(fileObject.extension)) {
return await extractCoverFromComicBookArchive({
...targetOptions, ...targetOptions,
paginationOptions: pagingConfig, paginationOptions: pagingConfig,
folderDetails: fileObject, },
}); fileObjects,
} );
});
}; };