From 524f8179f44df53448698e5970eb7037255b8c38 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 4 Aug 2021 08:55:02 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Changed=20the=20type=20schema=20?= =?UTF-8?q?in=20uncompression=20utils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/comic.model.ts | 4 ++++ package-lock.json | 14 +++++++------- package.json | 2 +- utils/imagetransformation.utils.ts | 4 ---- utils/uncompression.utils.ts | 14 ++++++++++---- yarn.lock | 8 ++++---- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/models/comic.model.ts b/models/comic.model.ts index 3c16297..21f15f5 100644 --- a/models/comic.model.ts +++ b/models/comic.model.ts @@ -37,7 +37,11 @@ const ComicSchema = mongoose.Schema({ name: String, path: String, fileSize: Number, + extension: String, containedIn: String, + calibreMetadata :{ + coverWriteResult: String, + } }, acquisition: { wanted: Boolean, diff --git a/package-lock.json b/package-lock.json index cdf8666..fb9bdb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "jest": "^25.1.0", "jest-cli": "^25.1.0", "moleculer-repl": "^0.6.2", - "threetwo-ui-typings": "^1.0.1-0", + "threetwo-ui-typings": "^1.0.2-0", "ts-jest": "^25.3.0", "ts-node": "^8.8.1" }, @@ -11291,9 +11291,9 @@ "dev": true }, "node_modules/threetwo-ui-typings": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/threetwo-ui-typings/-/threetwo-ui-typings-1.0.1.tgz", - "integrity": "sha512-g5FWa069AT1WfUHHEVFOQ1q6cfK+9UOzewfKblheuDBSsGN/e89MJMEVfuInBaHgxHM32/P+mNUFBqnBoeRSLQ==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/threetwo-ui-typings/-/threetwo-ui-typings-1.0.2.tgz", + "integrity": "sha512-sK5cb/fApFKseQNgcnGmAnPNxDDXT+dQ/Blei1N4q0mduO3kZfJTnlMYaXjO4FDXLP+jkiwsv0bf7PXm0DgF7g==", "dev": true, "dependencies": { "typescript": "^4.3.2" @@ -21059,9 +21059,9 @@ "dev": true }, "threetwo-ui-typings": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/threetwo-ui-typings/-/threetwo-ui-typings-1.0.1.tgz", - "integrity": "sha512-g5FWa069AT1WfUHHEVFOQ1q6cfK+9UOzewfKblheuDBSsGN/e89MJMEVfuInBaHgxHM32/P+mNUFBqnBoeRSLQ==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/threetwo-ui-typings/-/threetwo-ui-typings-1.0.2.tgz", + "integrity": "sha512-sK5cb/fApFKseQNgcnGmAnPNxDDXT+dQ/Blei1N4q0mduO3kZfJTnlMYaXjO4FDXLP+jkiwsv0bf7PXm0DgF7g==", "dev": true, "requires": { "typescript": "^4.3.2" diff --git a/package.json b/package.json index f8bec7c..e8165e9 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "jest": "^25.1.0", "jest-cli": "^25.1.0", "moleculer-repl": "^0.6.2", - "threetwo-ui-typings": "^1.0.1-0", + "threetwo-ui-typings": "^1.0.2-0", "ts-jest": "^25.3.0", "ts-node": "^8.8.1" }, diff --git a/utils/imagetransformation.utils.ts b/utils/imagetransformation.utils.ts index 7e9cfc9..e3e7bcf 100644 --- a/utils/imagetransformation.utils.ts +++ b/utils/imagetransformation.utils.ts @@ -1,8 +1,4 @@ const sharp = require("sharp"); -const imghash = require("imghash"); -const leven = require("leven"); -import path from "path"; -import { isNull, reject } from "lodash"; import { logger } from "./logger.utils"; import { ISharpResizedImageStats } from "threetwo-ui-typings"; diff --git a/utils/uncompression.utils.ts b/utils/uncompression.utils.ts index 9ccba23..58efc6c 100644 --- a/utils/uncompression.utils.ts +++ b/utils/uncompression.utils.ts @@ -97,14 +97,16 @@ export const extractCoverFromFile = async ( // create renditions const renditionPath = constructedPaths.targetPath + "/" + walkedFolder.name + "_200px.jpg"; const stats:ISharpResizedImageStats = await resizeImage(targetCoverImageFilePath, path.resolve(renditionPath), 200); - + resolve({ name: walkedFolder.name, - path: constructedPaths.targetPath + "/" + walkedFolder.name + "_200px.jpg", //renditionPath + path: renditionPath, fileSize: stats.size, + extension: path.extname(constructedPaths.inputFilePath), containedIn: walkedFolder.containedIn, - //originalPath: - //extension: + calibreMetadata: { + coverWriteResult: result, + } }); } catch (error) { console.log(error); @@ -239,8 +241,12 @@ export const unrar = async ( resolve({ name: `${extractedFiles[0].fileHeader.name}`, path: paths.targetPath, + extension: path.extname(extractedFiles[0].fileHeader.name), fileSize: extractedFiles[0].fileHeader.packSize, containedIn: walkedFolder.containedIn, + calibreMetadata: { + coverWriteResult: "", + } }); } catch (error) { logger.error(`${error}: Couldn't write file.`); diff --git a/yarn.lock b/yarn.lock index 62247b4..f8dd3bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5896,10 +5896,10 @@ "resolved" "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz" "version" "0.2.0" -"threetwo-ui-typings@^1.0.1-0": - "integrity" "sha512-g5FWa069AT1WfUHHEVFOQ1q6cfK+9UOzewfKblheuDBSsGN/e89MJMEVfuInBaHgxHM32/P+mNUFBqnBoeRSLQ==" - "resolved" "https://registry.npmjs.org/threetwo-ui-typings/-/threetwo-ui-typings-1.0.1.tgz" - "version" "1.0.1" +"threetwo-ui-typings@^1.0.2-0": + "integrity" "sha512-sK5cb/fApFKseQNgcnGmAnPNxDDXT+dQ/Blei1N4q0mduO3kZfJTnlMYaXjO4FDXLP+jkiwsv0bf7PXm0DgF7g==" + "resolved" "https://registry.npmjs.org/threetwo-ui-typings/-/threetwo-ui-typings-1.0.2.tgz" + "version" "1.0.2" dependencies: "typescript" "^4.3.2"