瀏覽代碼

Поправки FileDownloader

Book Pauk 2 年之前
父節點
當前提交
f30f11ce2d
共有 2 個文件被更改,包括 6 次插入3 次删除
  1. 5 2
      server/core/FileDownloader.js
  2. 1 1
      server/core/Reader/ReaderWorker.js

+ 5 - 2
server/core/FileDownloader.js

@@ -9,11 +9,12 @@ class FileDownloader {
         this.limitDownloadSize = limitDownloadSize;
     }
 
-    async load(url, callback, abort) {
+    async load(url, opts, callback, abort) {
         let errMes = '';
 
-        const options = {
+        let options = {
             headers: {
+                'accept-encoding': 'gzip, compress, deflate',
                 'user-agent': userAgent,
                 timeout: 300*1000,
             },
@@ -22,6 +23,8 @@ class FileDownloader {
             }),
             responseType: 'stream',
         };
+        if (opts)
+            options = Object.assign({}, opts, options);
 
         try {
             const res = await axios.get(url, options);

+ 1 - 1
server/core/Reader/ReaderWorker.js

@@ -109,7 +109,7 @@ class ReaderWorker {
             let downloadSize = -1;
             //download or use uploaded
             if (url.indexOf('disk://') != 0) {//download
-                const downdata = await this.down.load(url, (progress) => {
+                const downdata = await this.down.load(url, {}, (progress) => {
                     wState.set({progress});
                 }, q.abort);