Работа над расширенным поиском

This commit is contained in:
Book Pauk
2022-12-01 17:09:21 +07:00
parent 68532e361e
commit 6160afa7f0
4 changed files with 41 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ module.exports = {
accessPassword: '',
accessTimeout: 0,
extendedSearch: true,
bookReadLink: '',
loggingEnabled: true,
@@ -30,7 +31,7 @@ module.exports = {
lowMemoryMode: false,
fullOptimization: false,
webConfigParams: ['name', 'version', 'branch', 'bookReadLink', 'dbVersion'],
webConfigParams: ['name', 'version', 'branch', 'bookReadLink', 'dbVersion', 'extendedSearch'],
allowRemoteLib: false,
remoteLib: false,

View File

@@ -7,6 +7,7 @@ const branchFilename = __dirname + '/application_env';
const propsToSave = [
'accessPassword',
'accessTimeout',
'extendedSearch',
'bookReadLink',
'loggingEnabled',
'dbCacheSize',

View File

@@ -261,7 +261,7 @@ class DbCreator {
//парсинг
const parser = new InpxParser();
await parser.parse(config.inpxFile, readFileCallback, parsedCallback);
await parser.parse(config.inpxFile, readFileCallback, parsedCallback);
//чистка памяти, ибо жрет как не в себя
authorMap = null;
@@ -448,7 +448,9 @@ class DbCreator {
const inpxInfo = (inpxFilter && inpxFilter.info ? inpxFilter.info : parser.info);
inpxInfo.structure = parser.info.structure;
if (!inpxInfo.version)
inpxInfo.version = parser.info.version;
await db.insert({table: 'config', rows: [
{id: 'inpxInfo', value: inpxInfo},
{id: 'stats', value: stats},

View File

@@ -1,12 +1,32 @@
const path = require('path');
const crypto = require('crypto');
const ZipReader = require('./ZipReader');
const utils = require('./utils');
const collectionInfo = 'collection.info';
const structureInfo = 'structure.info';
const versionInfo = 'version.info';
const defaultStructure = 'AUTHOR;GENRE;TITLE;SERIES;SERNO;FILE;SIZE;LIBID;DEL;EXT;DATE;LANG;LIBRATE;KEYWORDS';
//'AUTHOR;GENRE;TITLE;SERIES;SERNO;FILE;SIZE;LIBID;DEL;EXT;DATE;INSNO;FOLDER;LANG;LIBRATE;KEYWORDS;'
const defaultRecStruct = {
author: 'S',
genre: 'S',
title: 'S',
series: 'S',
serno: 'N',
file: 'S',
size: 'N',
libid: 'S',
del: 'N',
ext: 'S',
date: 'S',
insno: 'N',
folder: 'S',
lang: 'S',
librate: 'N',
keywords: 'S',
}
class InpxParser {
constructor() {
@@ -24,6 +44,18 @@ class InpxParser {
return result;
}
getRecStruct(structure) {
const result = {};
for (const field of structure)
if (utils.hasProp(defaultRecStruct, field))
result[field] = defaultRecStruct[field];
//folder есть всегда
result['folder'] = defaultRecStruct['folder'];
return result;
}
async parse(inpxFile, readFileCallback, parsedCallback) {
if (!readFileCallback)
readFileCallback = async() => {};
@@ -65,6 +97,8 @@ class InpxParser {
info.structure = defaultStructure;
const structure = info.structure.toLowerCase().split(';');
info.recStruct = this.getRecStruct(structure);
//парсим inp-файлы
this.chunk = [];
for (const inpFile of inpFiles) {