Работа над BookInfoDialog

This commit is contained in:
Book Pauk
2022-11-06 17:15:45 +07:00
parent 351abe9401
commit d9f1912ea2
7 changed files with 119 additions and 1 deletions

View File

@@ -84,6 +84,8 @@ class WebSocketController {
await this.getGenreTree(req, ws); break;
case 'get-book-link':
await this.getBookLink(req, ws); break;
case 'get-book-info':
await this.getBookInfo(req, ws); break;
case 'get-inpx-file':
await this.getInpxFile(req, ws); break;
@@ -173,6 +175,17 @@ class WebSocketController {
this.send(result, req, ws);
}
async getBookInfo(req, ws) {
if (!utils.hasProp(req, 'bookPath'))
throw new Error(`bookPath is empty`);
if (!utils.hasProp(req, 'downFileName'))
throw new Error(`downFileName is empty`);
const result = await this.webWorker.getBookInfo({bookPath: req.bookPath, downFileName: req.downFileName});
this.send(result, req, ws);
}
async getInpxFile(req, ws) {
if (!this.config.allowRemoteLib)
throw new Error('Remote lib access disabled');

View File

@@ -437,6 +437,26 @@ class WebWorker {
}
}
async getBookInfo(params) {
this.checkMyState();
try {
//const db = this.db;
let link = await this.getBookLink(params);
const hash = path.basename(link.link);
/*const bookFile = `${this.config.filesDir}/${hash}`;
const bookInfo = await fb2parser*/
return {hash};
} catch(e) {
log(LM_ERR, `getBookInfo error: ${e.message}`);
if (e.message.indexOf('ENOENT') >= 0)
throw new Error('404 Файл не найден');
throw e;
}
}
/*
async restoreBookFile(publicPath) {
this.checkMyState();