Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce7ae84e0f | ||
|
|
01eb545f15 | ||
|
|
706738c7f1 | ||
|
|
6afa78cde9 | ||
|
|
71f5710bba | ||
|
|
0d87043f91 | ||
|
|
e25375fb7a | ||
|
|
41822999c8 | ||
|
|
07444bc7c2 | ||
|
|
ec48e5b0b7 | ||
|
|
e8e2e9297f | ||
|
|
4f871dd5ca | ||
|
|
f5f07a591a | ||
|
|
4c11e6918f | ||
|
|
403b9c0508 | ||
|
|
ee8ba75371 | ||
|
|
a2773fb180 | ||
|
|
ca36d588fc |
@@ -593,12 +593,6 @@ class Reader extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshBookSplitToPara() {
|
|
||||||
if (this.mostRecentBook()) {
|
|
||||||
this.loadBook({url: this.mostRecentBook().url, skipCheck: true, isText: true, force: true});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
recentBooksClose() {
|
recentBooksClose() {
|
||||||
this.recentBooksActive = false;
|
this.recentBooksActive = false;
|
||||||
}
|
}
|
||||||
@@ -688,9 +682,14 @@ class Reader extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshBook() {
|
refreshBook(mode) {
|
||||||
if (this.mostRecentBook()) {
|
const mrb = this.mostRecentBook();
|
||||||
this.loadBook({url: this.mostRecentBook().url, force: true});
|
if (mrb) {
|
||||||
|
if (mode && mode == 'split') {
|
||||||
|
this.loadBook({url: mrb.url, uploadFileName: mrb.uploadFileName, skipCheck: true, isText: true, force: true});
|
||||||
|
} else {
|
||||||
|
this.loadBook({url: mrb.url, uploadFileName: mrb.uploadFileName, force: true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -882,6 +881,7 @@ class Reader extends Vue {
|
|||||||
wasOpened = (wasOpened ? wasOpened : {});
|
wasOpened = (wasOpened ? wasOpened : {});
|
||||||
const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
|
const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
|
||||||
const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
|
const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
|
||||||
|
const uploadFileName = (opts.uploadFileName ? opts.uploadFileName : '');
|
||||||
|
|
||||||
let book = null;
|
let book = null;
|
||||||
|
|
||||||
@@ -929,7 +929,7 @@ class Reader extends Vue {
|
|||||||
skipCheck: (opts.skipCheck ? true : false),
|
skipCheck: (opts.skipCheck ? true : false),
|
||||||
isText: (opts.isText ? true : false),
|
isText: (opts.isText ? true : false),
|
||||||
enableSitesFilter: this.enableSitesFilter,
|
enableSitesFilter: this.enableSitesFilter,
|
||||||
uploadFileName: (opts.uploadFileName ? opts.uploadFileName : ''),
|
uploadFileName
|
||||||
},
|
},
|
||||||
(state) => {
|
(state) => {
|
||||||
progress.setState(state);
|
progress.setState(state);
|
||||||
@@ -945,7 +945,7 @@ class Reader extends Vue {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// добавляем в историю
|
// добавляем в историю
|
||||||
await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, addedBook));
|
await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen, uploadFileName}, addedBook));
|
||||||
this.mostRecentBook();
|
this.mostRecentBook();
|
||||||
this.addAction(bookPos);
|
this.addAction(bookPos);
|
||||||
this.updateRoute(true);
|
this.updateRoute(true);
|
||||||
@@ -982,7 +982,7 @@ class Reader extends Vue {
|
|||||||
|
|
||||||
progress.hide(); this.progressActive = false;
|
progress.hide(); this.progressActive = false;
|
||||||
|
|
||||||
await this.loadBook({url, uploadFileName: opts.file.name});
|
await this.loadBook({url, uploadFileName: opts.file.name, force: true});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
progress.hide(); this.progressActive = false;
|
progress.hide(); this.progressActive = false;
|
||||||
this.loaderActive = true;
|
this.loaderActive = true;
|
||||||
@@ -1054,7 +1054,7 @@ class Reader extends Vue {
|
|||||||
this.copyTextToggle();
|
this.copyTextToggle();
|
||||||
break;
|
break;
|
||||||
case 'splitToPara':
|
case 'splitToPara':
|
||||||
this.refreshBookSplitToPara();
|
this.refreshBook('split');
|
||||||
break;
|
break;
|
||||||
case 'refresh':
|
case 'refresh':
|
||||||
this.refreshBook();
|
this.refreshBook();
|
||||||
|
|||||||
@@ -216,8 +216,15 @@ class ServerStorage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
error(message) {
|
error(message) {
|
||||||
if (this.showServerStorageMessages && !this.offlineModeActive)
|
if (this.showServerStorageMessages && !this.offlineModeActive) {
|
||||||
this.$root.notify.error(message);
|
this.errorMessageCounter = (this.errorMessageCounter ? this.errorMessageCounter + 1 : 1);
|
||||||
|
const hint = (this.errorMessageCounter < 2 ? '' :
|
||||||
|
'<div><br>Надоело это сообщение? Добавьте в настройках кнопку "Автономный режим" ' +
|
||||||
|
'<i class="la la-unlink" style="font-size: 20px; color: white"></i> на панель инструментов и активируйте ее.</div>'
|
||||||
|
);
|
||||||
|
|
||||||
|
this.$root.notify.error(message + hint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSettings(force = false, doNotifySuccess = true) {
|
async loadSettings(force = false, doNotifySuccess = true) {
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ sudo apt install rar
|
|||||||
sudo apt install libreoffice
|
sudo apt install libreoffice
|
||||||
sudo apt install poppler-utils
|
sudo apt install poppler-utils
|
||||||
sudo apt install djvulibre-bin
|
sudo apt install djvulibre-bin
|
||||||
|
sudo apt install libtiff-tools
|
||||||
|
sudo apt install graphicsmagick-imagemagick-compat
|
||||||
```
|
```
|
||||||
|
|
||||||
### nginx, server config
|
### nginx, server config
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
sudo -H -u www-data bash -c "cd /var/www; /home/liberama/liberama" &
|
sudo -H -u www-data bash -c "cd /var/www; /home/liberama/liberama" & disown
|
||||||
sudo service cron start
|
sudo service cron start
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class FileDecompressor {
|
|||||||
try {
|
try {
|
||||||
return await zip.unpack(filename, outputDir, {
|
return await zip.unpack(filename, outputDir, {
|
||||||
limitFileSize: this.limitFileSize,
|
limitFileSize: this.limitFileSize,
|
||||||
limitFileCount: 1000,
|
limitFileCount: 10000,
|
||||||
decodeEntryNameCallback: (nameRaw) => {
|
decodeEntryNameCallback: (nameRaw) => {
|
||||||
return utils.bufferRemoveZeroes(nameRaw);
|
return utils.bufferRemoveZeroes(nameRaw);
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ class FileDecompressor {
|
|||||||
fs.emptyDir(outputDir);
|
fs.emptyDir(outputDir);
|
||||||
return await zip.unpack(filename, outputDir, {
|
return await zip.unpack(filename, outputDir, {
|
||||||
limitFileSize: this.limitFileSize,
|
limitFileSize: this.limitFileSize,
|
||||||
limitFileCount: 1000,
|
limitFileCount: 10000,
|
||||||
decodeEntryNameCallback: (nameRaw) => {
|
decodeEntryNameCallback: (nameRaw) => {
|
||||||
nameRaw = utils.bufferRemoveZeroes(nameRaw);
|
nameRaw = utils.bufferRemoveZeroes(nameRaw);
|
||||||
const enc = textUtils.getEncodingLite(nameRaw);
|
const enc = textUtils.getEncodingLite(nameRaw);
|
||||||
@@ -171,7 +171,7 @@ class FileDecompressor {
|
|||||||
|
|
||||||
if (this.limitFileSize) {
|
if (this.limitFileSize) {
|
||||||
if ((await fs.stat(filename)).size > this.limitFileSize) {
|
if ((await fs.stat(filename)).size > this.limitFileSize) {
|
||||||
reject('Файл слишком большой');
|
reject(new Error('Файл слишком большой'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class LimitedQueue {
|
|||||||
get(onPlaceChange) {
|
get(onPlaceChange) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.destroyed)
|
if (this.destroyed)
|
||||||
reject('destroyed');
|
reject(new Error('destroyed'));
|
||||||
|
|
||||||
const take = () => {
|
const take = () => {
|
||||||
if (this.freed <= 0)
|
if (this.freed <= 0)
|
||||||
@@ -73,7 +73,7 @@ class LimitedQueue {
|
|||||||
if (onPlaceChange)
|
if (onPlaceChange)
|
||||||
onPlaceChange(this.listeners.length);
|
onPlaceChange(this.listeners.length);
|
||||||
} else {
|
} else {
|
||||||
reject('Превышен размер очереди ожидания');
|
reject(new Error('Превышен размер очереди ожидания'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class ConvertBase {
|
|||||||
this.calibrePath = `${config.dataDir}/calibre/ebook-convert`;
|
this.calibrePath = `${config.dataDir}/calibre/ebook-convert`;
|
||||||
this.sofficePath = '/usr/bin/soffice';
|
this.sofficePath = '/usr/bin/soffice';
|
||||||
this.pdfToHtmlPath = '/usr/bin/pdftohtml';
|
this.pdfToHtmlPath = '/usr/bin/pdftohtml';
|
||||||
this.ddjvuPath = '/usr/bin/ddjvu';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(data, opts) {// eslint-disable-line no-unused-vars
|
async run(data, opts) {// eslint-disable-line no-unused-vars
|
||||||
@@ -31,9 +30,6 @@ class ConvertBase {
|
|||||||
|
|
||||||
if (!await fs.pathExists(this.pdfToHtmlPath))
|
if (!await fs.pathExists(this.pdfToHtmlPath))
|
||||||
throw new Error('Внешний конвертер pdftohtml не найден');
|
throw new Error('Внешний конвертер pdftohtml не найден');
|
||||||
|
|
||||||
if (!await fs.pathExists(this.ddjvuPath))
|
|
||||||
throw new Error('Внешний конвертер ddjvu не найден');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async execConverter(path, args, onData, abort) {
|
async execConverter(path, args, onData, abort) {
|
||||||
@@ -46,21 +42,32 @@ class ConvertBase {
|
|||||||
throw new Error('Слишком большая очередь конвертирования. Пожалуйста, попробуйте позже.');
|
throw new Error('Слишком большая очередь конвертирования. Пожалуйста, попробуйте позже.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abort = (abort ? abort : () => false);
|
||||||
|
const myAbort = () => {
|
||||||
|
return q.abort() || abort();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (myAbort())
|
||||||
|
throw new Error('abort');
|
||||||
|
|
||||||
const result = await utils.spawnProcess(path, {
|
const result = await utils.spawnProcess(path, {
|
||||||
killAfter: 3600,//1 час
|
killAfter: 3600,//1 час
|
||||||
args,
|
args,
|
||||||
onData: (data) => {
|
onData: (data) => {
|
||||||
q.resetTimeout();
|
if (queue.freed > 0)
|
||||||
|
q.resetTimeout();
|
||||||
onData(data);
|
onData(data);
|
||||||
},
|
},
|
||||||
//будем периодически проверять работу конвертера и если очереди нет, то разрешаем работу пинком onData
|
//будем периодически проверять работу конвертера и если очереди нет, то разрешаем работу пинком onData
|
||||||
onUsage: (stats) => {
|
onUsage: (stats) => {
|
||||||
if (queue.freed > 1 && stats.cpu >= 10)
|
if (queue.freed > 0 && stats.cpu >= 10) {
|
||||||
|
q.resetTimeout();
|
||||||
onData('.');
|
onData('.');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onUsageInterval: 10,
|
onUsageInterval: 10,
|
||||||
abort
|
abort: myAbort
|
||||||
});
|
});
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
const error = `${result.code}|FORLOG|, exec: ${path}, args: ${args.join(' ')}, stdout: ${result.stdout}, stderr: ${result.stderr}`;
|
const error = `${result.code}|FORLOG|, exec: ${path}, args: ${args.join(' ')}, stdout: ${result.stdout}, stderr: ${result.stderr}`;
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const utils = require('../../utils');
|
||||||
|
|
||||||
const ConvertPdf = require('./ConvertPdf');
|
const ConvertHtml = require('./ConvertHtml');
|
||||||
|
|
||||||
class ConvertRtf extends ConvertPdf {
|
class ConvertDjvu extends ConvertHtml {
|
||||||
check(data, opts) {
|
check(data, opts) {
|
||||||
const {inputFiles} = opts;
|
const {inputFiles} = opts;
|
||||||
|
|
||||||
@@ -14,26 +15,88 @@ class ConvertRtf extends ConvertPdf {
|
|||||||
async run(data, opts) {
|
async run(data, opts) {
|
||||||
if (!this.check(data, opts))
|
if (!this.check(data, opts))
|
||||||
return false;
|
return false;
|
||||||
await this.checkExternalConverterPresent();
|
|
||||||
|
|
||||||
const {inputFiles, callback, abort} = opts;
|
const {inputFiles, callback, abort, uploadFileName} = opts;
|
||||||
|
|
||||||
const outFile = `${inputFiles.filesDir}/${path.basename(inputFiles.sourceFile)}`;
|
const ddjvuPath = '/usr/bin/ddjvu';
|
||||||
const pdfFile = `${outFile}.pdf`;
|
if (!await fs.pathExists(ddjvuPath))
|
||||||
|
throw new Error('Внешний конвертер ddjvu не найден');
|
||||||
|
|
||||||
|
const tiffsplitPath = '/usr/bin/tiffsplit';
|
||||||
|
if (!await fs.pathExists(tiffsplitPath))
|
||||||
|
throw new Error('Внешний конвертер tiffsplitPath не найден');
|
||||||
|
|
||||||
|
const mogrifyPath = '/usr/bin/mogrify';
|
||||||
|
if (!await fs.pathExists(mogrifyPath))
|
||||||
|
throw new Error('Внешний конвертер mogrifyPath не найден');
|
||||||
|
|
||||||
|
const dir = `${inputFiles.filesDir}/`;
|
||||||
|
const inpFile = `${dir}${path.basename(inputFiles.sourceFile)}`;
|
||||||
|
const tifFile = `${inpFile}.tif`;
|
||||||
|
|
||||||
|
//конвертируем в tiff
|
||||||
let perc = 0;
|
let perc = 0;
|
||||||
await this.execConverter(this.ddjvuPath, ['-format=pdf', '-quality=85', '-verbose', inputFiles.sourceFile, pdfFile], () => {
|
await this.execConverter(ddjvuPath, ['-format=tiff', '-quality=50', '-verbose', inputFiles.sourceFile, tifFile], () => {
|
||||||
perc = (perc < 100 ? perc + 1 : 40);
|
perc = (perc < 100 ? perc + 1 : 40);
|
||||||
callback(perc);
|
callback(perc);
|
||||||
}, abort);
|
}, abort);
|
||||||
|
|
||||||
const pdfFileSize = (await fs.stat(pdfFile)).size;
|
const tifFileSize = (await fs.stat(tifFile)).size;
|
||||||
if (pdfFileSize > 2*this.config.maxUploadFileSize) {
|
let limitSize = 3*this.config.maxUploadFileSize;
|
||||||
throw new Error(`Файл для конвертирования слишком большой|FORLOG| ${pdfFileSize} > ${2*this.config.maxUploadFileSize}`);
|
if (tifFileSize > limitSize) {
|
||||||
|
throw new Error(`Файл для конвертирования слишком большой|FORLOG| ${tifFileSize} > ${limitSize}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await super.run(null, Object.assign({}, opts, {pdfFile, skipCheck: true}));
|
//разбиваем на файлы
|
||||||
|
await this.execConverter(tiffsplitPath, [tifFile, dir], null, abort);
|
||||||
|
|
||||||
|
await fs.remove(tifFile);
|
||||||
|
|
||||||
|
//конвертируем в jpg
|
||||||
|
await this.execConverter(mogrifyPath, ['-quality', '20', '-scale', '2048', '-verbose', '-format', 'jpg', `${dir}*.tif`], () => {
|
||||||
|
perc = (perc < 100 ? perc + 1 : 40);
|
||||||
|
callback(perc);
|
||||||
|
}, abort);
|
||||||
|
|
||||||
|
//читаем изображения
|
||||||
|
const loadImage = async(image) => {
|
||||||
|
image.data = (await fs.readFile(image.file)).toString('base64');
|
||||||
|
image.name = path.basename(image.file);
|
||||||
|
}
|
||||||
|
|
||||||
|
let files = [];
|
||||||
|
await utils.findFiles(async(file) => {
|
||||||
|
if (path.extname(file) == '.jpg')
|
||||||
|
files.push({name: file, base: path.basename(file)});
|
||||||
|
}, dir);
|
||||||
|
|
||||||
|
files.sort((a, b) => a.base.localeCompare(b.base));
|
||||||
|
|
||||||
|
let images = [];
|
||||||
|
let loading = [];
|
||||||
|
files.forEach(f => {
|
||||||
|
const image = {file: f.name};
|
||||||
|
images.push(image);
|
||||||
|
loading.push(loadImage(image));
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all(loading);
|
||||||
|
|
||||||
|
//формируем текст
|
||||||
|
limitSize = 2*this.config.maxUploadFileSize;
|
||||||
|
let title = '';
|
||||||
|
if (uploadFileName)
|
||||||
|
title = uploadFileName;
|
||||||
|
let text = `<title>${title}</title>`;
|
||||||
|
for (const image of images) {
|
||||||
|
text += `<fb2-image type="image/jpeg" name="${image.name}">${image.data}</fb2-image>`;
|
||||||
|
|
||||||
|
if (text.length > limitSize) {
|
||||||
|
throw new Error(`Файл для конвертирования слишком большой|FORLOG| text.length: ${text.length} > ${limitSize}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await super.run(Buffer.from(text), {skipCheck: true, isText: true, cutTitle: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ConvertRtf;
|
module.exports = ConvertDjvu;
|
||||||
|
|||||||
@@ -14,15 +14,14 @@ class ConvertPdf extends ConvertHtml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(notUsed, opts) {
|
async run(notUsed, opts) {
|
||||||
if (!opts.skipCheck) {
|
if (!this.check(notUsed, opts))
|
||||||
if (!this.check(notUsed, opts))
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
await this.checkExternalConverterPresent();
|
await this.checkExternalConverterPresent();
|
||||||
|
|
||||||
const {inputFiles, callback, abort, uploadFileName} = opts;
|
const {inputFiles, callback, abort, uploadFileName} = opts;
|
||||||
|
|
||||||
const inpFile = (opts.pdfFile ? opts.pdfFile : inputFiles.sourceFile);
|
const inpFile = inputFiles.sourceFile;
|
||||||
const outFile = `${inputFiles.filesDir}/${utils.randomHexString(10)}.xml`;
|
const outFile = `${inputFiles.filesDir}/${utils.randomHexString(10)}.xml`;
|
||||||
|
|
||||||
//конвертируем в xml
|
//конвертируем в xml
|
||||||
@@ -189,12 +188,17 @@ class ConvertPdf extends ConvertHtml {
|
|||||||
indents[0] = 0;
|
indents[0] = 0;
|
||||||
|
|
||||||
//формируем текст
|
//формируем текст
|
||||||
|
const limitSize = 2*this.config.maxUploadFileSize;
|
||||||
if (!title && uploadFileName)
|
if (!title && uploadFileName)
|
||||||
title = uploadFileName;
|
title = uploadFileName;
|
||||||
let text = `<title>${title}</title>`;
|
let text = `<title>${title}</title>`;
|
||||||
let concat = '';
|
let concat = '';
|
||||||
let sp = '';
|
let sp = '';
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
|
if (text.length > limitSize) {
|
||||||
|
throw new Error(`Файл для конвертирования слишком большой|FORLOG| text.length: ${text.length} > ${limitSize}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (line.isImage) {
|
if (line.isImage) {
|
||||||
text += `<fb2-image type="${line.type}" name="${line.name}">${line.data}</fb2-image>`;
|
text += `<fb2-image type="${line.type}" name="${line.name}">${line.data}</fb2-image>`;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const utils = require('../utils');
|
|||||||
const log = new (require('../AppLogger'))().log;//singleton
|
const log = new (require('../AppLogger'))().log;//singleton
|
||||||
|
|
||||||
const cleanDirPeriod = 60*60*1000;//1 раз в час
|
const cleanDirPeriod = 60*60*1000;//1 раз в час
|
||||||
const queue = new LimitedQueue(5, 100, 4*60*1000);//4 минуты ожидание подвижек
|
const queue = new LimitedQueue(5, 100, 2*60*1000 + 15000);//2 минуты ожидание подвижек
|
||||||
|
|
||||||
let instance = null;
|
let instance = null;
|
||||||
|
|
||||||
@@ -130,7 +130,8 @@ class ReaderWorker {
|
|||||||
convertFilename = `${this.config.tempDownloadDir}/${tempFilename2}`;
|
convertFilename = `${this.config.tempDownloadDir}/${tempFilename2}`;
|
||||||
await this.bookConverter.convertToFb2(decompFiles, convertFilename, opts, progress => {
|
await this.bookConverter.convertToFb2(decompFiles, convertFilename, opts, progress => {
|
||||||
wState.set({progress});
|
wState.set({progress});
|
||||||
q.resetTimeout();
|
if (queue.freed > 0)
|
||||||
|
q.resetTimeout();
|
||||||
}, q.abort);
|
}, q.abort);
|
||||||
|
|
||||||
//сжимаем файл в tmp, если там уже нет с тем же именем-sha256
|
//сжимаем файл в tmp, если там уже нет с тем же именем-sha256
|
||||||
|
|||||||
@@ -76,13 +76,13 @@ class ZipStreamer {
|
|||||||
if (limitFileCount || limitFileSize || decodeEntryNameCallback) {
|
if (limitFileCount || limitFileSize || decodeEntryNameCallback) {
|
||||||
const entries = Object.values(unzip.entries());
|
const entries = Object.values(unzip.entries());
|
||||||
if (limitFileCount && entries.length > limitFileCount) {
|
if (limitFileCount && entries.length > limitFileCount) {
|
||||||
reject('Слишком много файлов');
|
reject(new Error('Слишком много файлов'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (limitFileSize && !entry.isDirectory && entry.size > limitFileSize) {
|
if (limitFileSize && !entry.isDirectory && entry.size > limitFileSize) {
|
||||||
reject('Файл слишком большой');
|
reject(new Error('Файл слишком большой'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user