Compare commits

..

11 Commits

Author SHA1 Message Date
Book Pauk
6afa78cde9 Merge branch 'release/0.9.10-3' 2020-12-05 01:40:30 +07:00
Book Pauk
71f5710bba Увеличен лимит количества файлов для распаковки 2020-12-05 01:12:29 +07:00
Book Pauk
0d87043f91 Поправлен неверный вызов reject 2020-12-05 01:11:31 +07:00
Book Pauk
e25375fb7a Поправка багов 2020-12-05 00:31:53 +07:00
Book Pauk
41822999c8 Небольшие поправки 2020-12-05 00:06:54 +07:00
Book Pauk
07444bc7c2 Добавлена подсказка в сообщение об ошибке 2020-12-04 23:25:34 +07:00
Book Pauk
ec48e5b0b7 Мелкая поправка 2020-12-04 20:14:53 +07:00
Book Pauk
e8e2e9297f Merge tag '0.9.10-2' into develop
0.9.10-2
2020-12-04 20:00:40 +07:00
Book Pauk
4f871dd5ca Merge branch 'release/0.9.10-2' 2020-12-04 20:00:35 +07:00
Book Pauk
f5f07a591a Небольшие доработки конвертирования 2020-12-04 20:00:05 +07:00
Book Pauk
4c11e6918f Merge tag '0.9.10-1' into develop
0.9.10-1
2020-12-04 18:38:02 +07:00
8 changed files with 46 additions and 30 deletions

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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

View File

@@ -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;
} }
} }

View File

@@ -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('Превышен размер очереди ожидания'));
} }
} }
}); });

View File

@@ -42,7 +42,7 @@ class ConvertDjvu extends ConvertHtml {
}, abort); }, abort);
const tifFileSize = (await fs.stat(tifFile)).size; const tifFileSize = (await fs.stat(tifFile)).size;
const limitSize = 3*this.config.maxUploadFileSize; let limitSize = 3*this.config.maxUploadFileSize;
if (tifFileSize > limitSize) { if (tifFileSize > limitSize) {
throw new Error(`Файл для конвертирования слишком большой|FORLOG| ${tifFileSize} > ${limitSize}`); throw new Error(`Файл для конвертирования слишком большой|FORLOG| ${tifFileSize} > ${limitSize}`);
} }
@@ -53,7 +53,7 @@ class ConvertDjvu extends ConvertHtml {
await fs.remove(tifFile); await fs.remove(tifFile);
//конвертируем в jpg //конвертируем в jpg
await this.execConverter(mogrifyPath, ['-quality', '20', '-verbose', '-format', 'jpg', `${dir}*.tif`], () => { await this.execConverter(mogrifyPath, ['-quality', '20', '-scale', '2048', '-verbose', '-format', 'jpg', `${dir}*.tif`], () => {
perc = (perc < 100 ? perc + 1 : 40); perc = (perc < 100 ? perc + 1 : 40);
callback(perc); callback(perc);
}, abort); }, abort);
@@ -83,12 +83,17 @@ class ConvertDjvu extends ConvertHtml {
await Promise.all(loading); await Promise.all(loading);
//формируем текст //формируем текст
limitSize = 2*this.config.maxUploadFileSize;
let title = ''; let title = '';
if (uploadFileName) if (uploadFileName)
title = uploadFileName; title = uploadFileName;
let text = `<title>${title}</title>`; let text = `<title>${title}</title>`;
for (const image of images) { for (const image of images) {
text += `<fb2-image type="image/jpeg" name="${image.name}">${image.data}</fb2-image>`; 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}); return await super.run(Buffer.from(text), {skipCheck: true, isText: true, cutTitle: true});
} }

View File

@@ -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;

View File

@@ -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;
} }