Улучшена работа с inpx, теперь понимает файлы в каталогах (без zip-архива)
This commit is contained in:
@@ -372,9 +372,19 @@ class WebWorker {
|
|||||||
async extractBook(bookPath) {
|
async extractBook(bookPath) {
|
||||||
const outFile = `${this.config.tempDir}/${utils.randomHexString(30)}`;
|
const outFile = `${this.config.tempDir}/${utils.randomHexString(30)}`;
|
||||||
|
|
||||||
const folder = `${this.config.libDir}/${path.dirname(bookPath)}`;
|
bookPath = bookPath.replace(/\\/g, '/').replace(/\/\//g, '/');
|
||||||
const file = path.basename(bookPath);
|
|
||||||
|
|
||||||
|
const i = bookPath.indexOf('/');
|
||||||
|
const folder = `${this.config.libDir}/${(i >= 0 ? bookPath.substring(0, i) : bookPath )}`;
|
||||||
|
const file = (i >= 0 ? bookPath.substring(i + 1) : '' );
|
||||||
|
|
||||||
|
const fullPath = `${folder}/${file}`;
|
||||||
|
|
||||||
|
if (!file || await fs.pathExists(fullPath)) {// файл есть на диске
|
||||||
|
|
||||||
|
await fs.copy(fullPath, outFile);
|
||||||
|
return outFile;
|
||||||
|
} else {// файл в zip-архиве
|
||||||
const zipReader = new ZipReader();
|
const zipReader = new ZipReader();
|
||||||
await zipReader.open(folder);
|
await zipReader.open(folder);
|
||||||
|
|
||||||
@@ -385,6 +395,7 @@ class WebWorker {
|
|||||||
await zipReader.close();
|
await zipReader.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async restoreBook(bookUid, bookPath, downFileName) {
|
async restoreBook(bookUid, bookPath, downFileName) {
|
||||||
const db = this.db;
|
const db = this.db;
|
||||||
|
|||||||
Reference in New Issue
Block a user