✏️ Adding the scaffold for full extraction of rar and zips

This commit is contained in:
2022-04-22 01:26:22 -07:00
parent e7e230503e
commit bb9dbc2e47
2 changed files with 25 additions and 21 deletions

View File

@@ -42,7 +42,6 @@ const brokerConfig: BrokerOptions = {
// Enable/disable logging or use custom logger. More info: https://moleculer.services/docs/0.14/logging.html
// Available logger types: "Console", "File", "Pino", "Winston", "Bunyan", "debug", "Log4js", "Datadog"
logger: [
{
type: "Console",
options: {
@@ -81,11 +80,11 @@ const brokerConfig: BrokerOptions = {
// Default log level for built-in console logger. It can be overwritten in logger options above.
// Available values: trace, debug, info, warn, error, fatal
logLevel: {
"TRACING": "trace",
"TRANS*": "warn",
"GREETER": "debug",
"**": "info",
},
TRACING: "trace",
"TRANS*": "warn",
GREETER: "debug",
"**": "info",
},
// Define transporter.
// More info: https://moleculer.services/docs/0.14/networking.html
@@ -205,7 +204,7 @@ const brokerConfig: BrokerOptions = {
// Enable built-in tracing function. More info: https://moleculer.services/docs/0.14/tracing.html
tracing: {
enabled: false,
enabled: true,
// Available built-in exporters: "Console", "Datadog", "Event", "EventLegacy", "Jaeger", "Zipkin"
exporter: {
type: "Console", // Console exporter is only for development!

View File

@@ -31,13 +31,7 @@ SOFTWARE.
* Initial: 2021/05/04 Rishi Ghan
*/
import {
createReadStream, createWriteStream,
existsSync
} from "fs";
import { createReadStream, createWriteStream, existsSync } from "fs";
import { isEmpty, isNil, isUndefined, remove } from "lodash";
import * as p7zip from "p7zip-threetwo";
import path from "path";
@@ -199,7 +193,7 @@ export const extractComicInfoXMLFromZip = async (
({ name }) => !IMPORT_IMAGE_FILE_FORMATS.includes(path.extname(name))
);
// detect comicinfo.xml
// detect ComicInfo.xml
const comicInfoXMLFileObject = remove(
filesFromArchive.files,
(file) => path.basename(file.name.toLowerCase()) === "comicinfo.xml"
@@ -304,19 +298,16 @@ export const extractComicInfoXMLFromZip = async (
export const extractFromArchive = async (filePath: string) => {
console.info(`Unrar is located at: ${UNRAR_BIN_PATH}`);
const { extension } = getFileConstituents(filePath);
console.log(
`Detected file type is ${extension}, looking for comicinfo.xml...`
);
switch (extension) {
case ".cbz":
case ".cb7":
console.log(
"Detected file type is cbz, looking for comicinfo.xml..."
);
const cbzResult = await extractComicInfoXMLFromZip(filePath);
return Object.assign({}, ...cbzResult);
case ".cbr":
console.log(
"Detected file type is cbr, looking for comicinfo.xml..."
);
const cbrResult = await extractComicInfoXMLFromRar(filePath);
return Object.assign({}, ...cbrResult);
@@ -327,3 +318,17 @@ export const extractFromArchive = async (filePath: string) => {
break;
}
};
export const uncompressEntireArchive = async (filePath: string) => {
const { extension } = getFileConstituents(filePath);
switch (extension) {
case ".cbz":
case ".cb7":
return await uncompressZipArchive(filePath);
case ".cbr":
return await uncompressRarArchive(filePath);
}
};
export const uncompressZipArchive = async (filePath: string) => { };
export const uncompressRarArchive = async (filePath: string) => { };