|
@@ -27,6 +27,7 @@ class ReaderWorker {
|
|
let errMes = '';
|
|
let errMes = '';
|
|
let decompDir = '';
|
|
let decompDir = '';
|
|
let downloadedFilename = '';
|
|
let downloadedFilename = '';
|
|
|
|
+ let isUploaded = false;
|
|
let convertFilename = '';
|
|
let convertFilename = '';
|
|
try {
|
|
try {
|
|
wState.set({state: 'download', step: 1, totalSteps: 3, url});
|
|
wState.set({state: 'download', step: 1, totalSteps: 3, url});
|
|
@@ -35,13 +36,19 @@ class ReaderWorker {
|
|
const tempFilename2 = utils.randomHexString(30);
|
|
const tempFilename2 = utils.randomHexString(30);
|
|
const decompDirname = utils.randomHexString(30);
|
|
const decompDirname = utils.randomHexString(30);
|
|
|
|
|
|
- //download
|
|
|
|
- const downdata = await this.down.load(url, (progress) => {
|
|
|
|
- wState.set({progress});
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- downloadedFilename = `${this.config.tempDownloadDir}/${tempFilename}`;
|
|
|
|
- await fs.writeFile(downloadedFilename, downdata);
|
|
|
|
|
|
+ if (url.indexOf('file://') != 0) {//download
|
|
|
|
+ const downdata = await this.down.load(url, (progress) => {
|
|
|
|
+ wState.set({progress});
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ downloadedFilename = `${this.config.tempDownloadDir}/${tempFilename}`;
|
|
|
|
+ await fs.writeFile(downloadedFilename, downdata);
|
|
|
|
+ } else {//uploaded file
|
|
|
|
+ downloadedFilename = `${this.config.uploadDir}/${url.substr(7)}`;
|
|
|
|
+ if (!await fs.pathExists(downloadedFilename))
|
|
|
|
+ throw new Error('Файл не найден на сервере (возможно был удален как устаревший). Пожалуйста, загрузите файл с диска на сервер заново.');
|
|
|
|
+ isUploaded = true;
|
|
|
|
+ }
|
|
wState.set({progress: 100});
|
|
wState.set({progress: 100});
|
|
|
|
|
|
//decompress
|
|
//decompress
|
|
@@ -73,7 +80,7 @@ class ReaderWorker {
|
|
//clean
|
|
//clean
|
|
if (decompDir)
|
|
if (decompDir)
|
|
await fs.remove(decompDir);
|
|
await fs.remove(decompDir);
|
|
- if (downloadedFilename)
|
|
|
|
|
|
+ if (downloadedFilename && !isUploaded)
|
|
await fs.remove(downloadedFilename);
|
|
await fs.remove(downloadedFilename);
|
|
if (convertFilename)
|
|
if (convertFilename)
|
|
await fs.remove(convertFilename);
|
|
await fs.remove(convertFilename);
|