From 9b29ee39b04caf16c3a6fe6969333ae5cb763151 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:34:11 +0100 Subject: [PATCH] Ensure originalLibraryFile has relevant scan data --- .../FlowHelpers/1.0.0/classicPlugins.js | 41 ++++++++++++------- .../FlowHelpers/1.0.0/classicPlugins.ts | 36 ++++++++++------ 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/FlowPlugins/FlowHelpers/1.0.0/classicPlugins.js b/FlowPlugins/FlowHelpers/1.0.0/classicPlugins.js index bc563f71d..f37b54528 100644 --- a/FlowPlugins/FlowHelpers/1.0.0/classicPlugins.js +++ b/FlowPlugins/FlowHelpers/1.0.0/classicPlugins.js @@ -40,7 +40,7 @@ exports.runClassicPlugin = void 0; var fs_1 = require("fs"); var fileUtils_1 = require("./fileUtils"); var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0, void 0, function () { - var path, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, pluginSrcStr, res, container, cacheFilePath, otherArguments, scanTypes, pluginInputFileObj, result; + var path, pluginSourceId, parts, pluginSource, pluginId, relativePluginPath, absolutePath, classicPlugin, pluginSrcStr, res, container, cacheFilePath, scanTypes, pluginInputFileObj, originalLibraryFile, otherArguments, result; var _a; return __generator(this, function (_b) { switch (_b.label) { @@ -98,19 +98,6 @@ var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0, case 9: container = (0, fileUtils_1.getContainer)(args.inputFileObj._id); cacheFilePath = "".concat((0, fileUtils_1.getPluginWorkDir)(args), "/").concat((0, fileUtils_1.getFileName)(args.inputFileObj._id), ".").concat(container); - otherArguments = { - handbrakePath: args.handbrakePath, - ffmpegPath: args.ffmpegPath, - mkvpropeditPath: args.mkvpropeditPath, - originalLibraryFile: args.originalLibraryFile, - nodeHardwareType: args.nodeHardwareType, - pluginCycle: 0, - workerType: args.workerType, - version: args.config.version, - platform_arch_isdocker: args.platform_arch_isdocker, - cacheFilePath: cacheFilePath, - job: args.job, - }; scanTypes = (0, fileUtils_1.getScanTypes)([pluginSrcStr]); return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/scan-individual-file', { file: { @@ -123,8 +110,32 @@ var runClassicPlugin = function (args, type) { return __awaiter(void 0, void 0, })]; case 10: pluginInputFileObj = _b.sent(); - return [4 /*yield*/, classicPlugin.plugin(pluginInputFileObj, args.librarySettings, args.inputs, otherArguments)]; + return [4 /*yield*/, args.deps.axiosMiddleware('api/v2/scan-individual-file', { + file: { + _id: args.originalLibraryFile._id, + file: args.originalLibraryFile.file, + DB: args.originalLibraryFile.DB, + footprintId: args.originalLibraryFile.footprintId, + }, + scanTypes: scanTypes, + })]; case 11: + originalLibraryFile = _b.sent(); + otherArguments = { + handbrakePath: args.handbrakePath, + ffmpegPath: args.ffmpegPath, + mkvpropeditPath: args.mkvpropeditPath, + originalLibraryFile: originalLibraryFile, + nodeHardwareType: args.nodeHardwareType, + pluginCycle: 0, + workerType: args.workerType, + version: args.config.version, + platform_arch_isdocker: args.platform_arch_isdocker, + cacheFilePath: cacheFilePath, + job: args.job, + }; + return [4 /*yield*/, classicPlugin.plugin(pluginInputFileObj, args.librarySettings, args.inputs, otherArguments)]; + case 12: result = _b.sent(); if (((_a = result === null || result === void 0 ? void 0 : result.file) === null || _a === void 0 ? void 0 : _a._id) && args.inputFileObj._id !== result.file._id) { // eslint-disable-next-line no-param-reassign diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/classicPlugins.ts b/FlowPluginsTs/FlowHelpers/1.0.0/classicPlugins.ts index c0615da29..00c89773e 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/classicPlugins.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/classicPlugins.ts @@ -88,11 +88,33 @@ export const runClassicPlugin = async (args:IpluginInputArgs, type:'filter'|'tra const container = getContainer(args.inputFileObj._id); const cacheFilePath = `${getPluginWorkDir(args)}/${getFileName(args.inputFileObj._id)}.${container}`; + const scanTypes = getScanTypes([pluginSrcStr]); + + const pluginInputFileObj = await args.deps.axiosMiddleware('api/v2/scan-individual-file', { + file: { + _id: args.inputFileObj._id, + file: args.inputFileObj.file, + DB: args.inputFileObj.DB, + footprintId: args.inputFileObj.footprintId, + }, + scanTypes, + }); + + const originalLibraryFile = await args.deps.axiosMiddleware('api/v2/scan-individual-file', { + file: { + _id: args.originalLibraryFile._id, + file: args.originalLibraryFile.file, + DB: args.originalLibraryFile.DB, + footprintId: args.originalLibraryFile.footprintId, + }, + scanTypes, + }); + const otherArguments = { handbrakePath: args.handbrakePath, ffmpegPath: args.ffmpegPath, mkvpropeditPath: args.mkvpropeditPath, - originalLibraryFile: args.originalLibraryFile, + originalLibraryFile, nodeHardwareType: args.nodeHardwareType, pluginCycle: 0, workerType: args.workerType, @@ -102,18 +124,6 @@ export const runClassicPlugin = async (args:IpluginInputArgs, type:'filter'|'tra job: args.job, }; - const scanTypes = getScanTypes([pluginSrcStr]); - - const pluginInputFileObj = await args.deps.axiosMiddleware('api/v2/scan-individual-file', { - file: { - _id: args.inputFileObj._id, - file: args.inputFileObj.file, - DB: args.inputFileObj.DB, - footprintId: args.inputFileObj.footprintId, - }, - scanTypes, - }); - const result = await classicPlugin.plugin( pluginInputFileObj, args.librarySettings,