浏览代码

Merge branch 'release/0.9.10-3'

Book Pauk 4 年之前
父节点
当前提交
6afa78cde9

+ 13 - 13
client/components/Reader/Reader.vue

@@ -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() {
         this.recentBooksActive = false;
     }
@@ -688,9 +682,14 @@ class Reader extends Vue {
         }
     }
 
-    refreshBook() {
-        if (this.mostRecentBook()) {
-            this.loadBook({url: this.mostRecentBook().url, force: true});
+    refreshBook(mode) {
+        const mrb = this.mostRecentBook();
+        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 : {});
             const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
             const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
+            const uploadFileName = (opts.uploadFileName ? opts.uploadFileName : '');
 
             let book = null;
 
@@ -929,7 +929,7 @@ class Reader extends Vue {
                         skipCheck: (opts.skipCheck ? true : false),
                         isText: (opts.isText ? true : false),
                         enableSitesFilter: this.enableSitesFilter,
-                        uploadFileName: (opts.uploadFileName ? opts.uploadFileName : ''),
+                        uploadFileName
                     },
                     (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.addAction(bookPos);
             this.updateRoute(true);
@@ -982,7 +982,7 @@ class Reader extends Vue {
 
             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) {
             progress.hide(); this.progressActive = false;
             this.loaderActive = true;
@@ -1054,7 +1054,7 @@ class Reader extends Vue {
                 this.copyTextToggle();
                 break;
             case 'splitToPara':
-                this.refreshBookSplitToPara();
+                this.refreshBook('split');
                 break;
             case 'refresh':
                 this.refreshBook();

+ 9 - 2
client/components/Reader/ServerStorage/ServerStorage.vue

@@ -216,8 +216,15 @@ class ServerStorage extends Vue {
     }
 
     error(message) {
-        if (this.showServerStorageMessages && !this.offlineModeActive)
-            this.$root.notify.error(message);
+        if (this.showServerStorageMessages && !this.offlineModeActive) {
+            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) {

+ 1 - 1
docs/omnireader.ru/start_server.sh

@@ -1,4 +1,4 @@
 #!/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

+ 3 - 3
server/core/FileDecompressor.js

@@ -135,7 +135,7 @@ class FileDecompressor {
         try {
             return await zip.unpack(filename, outputDir, {
                 limitFileSize: this.limitFileSize, 
-                limitFileCount: 1000,
+                limitFileCount: 10000,
                 decodeEntryNameCallback: (nameRaw) => {
                     return utils.bufferRemoveZeroes(nameRaw);
                 }
@@ -144,7 +144,7 @@ class FileDecompressor {
             fs.emptyDir(outputDir);
             return await zip.unpack(filename, outputDir, {
                 limitFileSize: this.limitFileSize, 
-                limitFileCount: 1000,
+                limitFileCount: 10000,
                 decodeEntryNameCallback: (nameRaw) => {
                     nameRaw = utils.bufferRemoveZeroes(nameRaw);
                     const enc = textUtils.getEncodingLite(nameRaw);
@@ -171,7 +171,7 @@ class FileDecompressor {
 
             if (this.limitFileSize) {
                 if ((await fs.stat(filename)).size > this.limitFileSize) {
-                    reject('Файл слишком большой');
+                    reject(new Error('Файл слишком большой'));
                     return;
                 }
             }

+ 2 - 2
server/core/LimitedQueue.js

@@ -28,7 +28,7 @@ class LimitedQueue {
     get(onPlaceChange) {
         return new Promise((resolve, reject) => {
             if (this.destroyed)
-                reject('destroyed');
+                reject(new Error('destroyed'));
 
             const take = () => {
                 if (this.freed <= 0)
@@ -73,7 +73,7 @@ class LimitedQueue {
                     if (onPlaceChange)
                         onPlaceChange(this.listeners.length);
                 } else {
-                    reject('Превышен размер очереди ожидания');
+                    reject(new Error('Превышен размер очереди ожидания'));
                 }
             }
         });

+ 9 - 5
server/core/Reader/BookConverter/ConvertPdf.js

@@ -14,15 +14,14 @@ class ConvertPdf extends ConvertHtml {
     }
 
     async run(notUsed, opts) {
-        if (!opts.skipCheck) {
-            if (!this.check(notUsed, opts))
-                return false;
-        }
+        if (!this.check(notUsed, opts))
+            return false;
+
         await this.checkExternalConverterPresent();
 
         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`;
 
         //конвертируем в xml
@@ -189,12 +188,17 @@ class ConvertPdf extends ConvertHtml {
         indents[0] = 0;
 
         //формируем текст
+        const limitSize = 2*this.config.maxUploadFileSize;
         if (!title && uploadFileName)
             title = uploadFileName;
         let text = `<title>${title}</title>`;
         let concat = '';
         let sp = '';
         for (const line of lines) {
+            if (text.length > limitSize) {
+                throw new Error(`Файл для конвертирования слишком большой|FORLOG| text.length: ${text.length} > ${limitSize}`);
+            }
+            
             if (line.isImage) {
                 text += `<fb2-image type="${line.type}" name="${line.name}">${line.data}</fb2-image>`;
                 continue;

+ 2 - 2
server/core/Zip/ZipStreamer.js

@@ -76,13 +76,13 @@ class ZipStreamer {
                 if (limitFileCount || limitFileSize || decodeEntryNameCallback) {
                     const entries = Object.values(unzip.entries());
                     if (limitFileCount && entries.length > limitFileCount) {
-                        reject('Слишком много файлов');
+                        reject(new Error('Слишком много файлов'));
                         return;
                     }
 
                     for (const entry of entries) {
                         if (limitFileSize && !entry.isDirectory && entry.size > limitFileSize) {
-                            reject('Файл слишком большой');
+                            reject(new Error('Файл слишком большой'));
                             return;
                         }