Merge branch 'release/0.9.10-3'

This commit is contained in:
Book Pauk
2020-12-05 01:40:30 +07:00
7 changed files with 39 additions and 28 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

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