Небольшие исправления, queue теперь в одном экземпляре на класс
This commit is contained in:
@@ -7,6 +7,8 @@ const LimitedQueue = require('../../LimitedQueue');
|
||||
const textUtils = require('./textUtils');
|
||||
const utils = require('../../utils');
|
||||
|
||||
const queue = new LimitedQueue(2, 20, 3*60*1000);//3 минуты ожидание подвижек
|
||||
|
||||
class ConvertBase {
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
@@ -14,7 +16,6 @@ class ConvertBase {
|
||||
this.calibrePath = `${config.dataDir}/calibre/ebook-convert`;
|
||||
this.sofficePath = '/usr/bin/soffice';
|
||||
this.pdfToHtmlPath = '/usr/bin/pdftohtml';
|
||||
this.queue = new LimitedQueue(2, 20, 3*60*1000);//3 минуты ожидание подвижек
|
||||
}
|
||||
|
||||
async run(data, opts) {// eslint-disable-line no-unused-vars
|
||||
@@ -35,7 +36,7 @@ class ConvertBase {
|
||||
async execConverter(path, args, onData, abort) {
|
||||
let q = null;
|
||||
try {
|
||||
q = await this.queue.get(() => {onData();});
|
||||
q = await queue.get(() => {onData();});
|
||||
} catch (e) {
|
||||
throw new Error('Слишком большая очередь конвертирования. Пожалуйста, попробуйте позже.');
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ const utils = require('../utils');
|
||||
const log = new (require('../AppLogger'))().log;//singleton
|
||||
|
||||
const cleanDirPeriod = 60*60*1000;//1 раз в час
|
||||
const queue = new LimitedQueue(5, 100, 5*60*1000);//5 минут ожидание подвижек
|
||||
|
||||
let instance = null;
|
||||
|
||||
@@ -27,7 +28,6 @@ class ReaderWorker {
|
||||
this.config.tempPublicDir = `${config.publicDir}/tmp`;
|
||||
fs.ensureDirSync(this.config.tempPublicDir);
|
||||
|
||||
this.queue = new LimitedQueue(5, 100, 5*60*1000);//5 минут ожидание подвижек
|
||||
this.workerState = new WorkerState();
|
||||
this.down = new FileDownloader(config.maxUploadFileSize);
|
||||
this.decomp = new FileDecompressor(2*config.maxUploadFileSize);
|
||||
@@ -64,7 +64,7 @@ class ReaderWorker {
|
||||
wState.set({state: 'queue', step: 1, totalSteps: 1});
|
||||
try {
|
||||
let qSize = 0;
|
||||
q = await this.queue.get((place) => {
|
||||
q = await queue.get((place) => {
|
||||
wState.set({place, progress: (qSize ? Math.round((qSize - place)/qSize*100) : 0)});
|
||||
if (!qSize)
|
||||
qSize = place;
|
||||
|
||||
Reference in New Issue
Block a user