Поправки для поддержки reverse-proxy, рефакторинг
This commit is contained in:
@@ -68,7 +68,8 @@ class RemoteLib {
|
||||
|
||||
const buf = await this.down.load(`${this.remoteHost}${link}`, {decompress: false});
|
||||
|
||||
const publicPath = `${this.config.publicFilesDir}${link}`;
|
||||
const hash = path.basename(link);
|
||||
const publicPath = `${this.config.bookDir}/${hash}`;
|
||||
|
||||
await fs.writeFile(publicPath, buf);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class WebWorker {
|
||||
|
||||
const dirConfig = [
|
||||
{
|
||||
dir: config.filesDir,
|
||||
dir: config.bookDir,
|
||||
maxSize: config.maxFilesDirSize,
|
||||
},
|
||||
];
|
||||
@@ -380,8 +380,8 @@ class WebWorker {
|
||||
hash = await this.remoteLib.downloadBook(bookUid);
|
||||
}
|
||||
|
||||
const link = `${this.config.filesPathStatic}/${hash}`;
|
||||
const bookFile = `${this.config.filesDir}/${hash}`;
|
||||
const link = `${this.config.bookPathStatic}/${hash}`;
|
||||
const bookFile = `${this.config.bookDir}/${hash}`;
|
||||
const bookFileDesc = `${bookFile}.d.json`;
|
||||
|
||||
if (!await fs.pathExists(bookFile) || !await fs.pathExists(bookFileDesc)) {
|
||||
@@ -447,11 +447,11 @@ class WebWorker {
|
||||
rows = await db.select({table: 'file_hash', where: `@@id(${db.esc(bookPath)})`});
|
||||
if (rows.length) {//хеш найден по bookPath
|
||||
const hash = rows[0].hash;
|
||||
const bookFile = `${this.config.filesDir}/${hash}`;
|
||||
const bookFile = `${this.config.bookDir}/${hash}`;
|
||||
const bookFileDesc = `${bookFile}.d.json`;
|
||||
|
||||
if (await fs.pathExists(bookFile) && await fs.pathExists(bookFileDesc)) {
|
||||
link = `${this.config.filesPathStatic}/${hash}`;
|
||||
link = `${this.config.bookPathStatic}/${hash}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ class WebWorker {
|
||||
|
||||
let bookInfo = await this.getBookLink(bookUid);
|
||||
const hash = path.basename(bookInfo.link);
|
||||
const bookFile = `${this.config.filesDir}/${hash}`;
|
||||
const bookFile = `${this.config.bookDir}/${hash}`;
|
||||
const bookFileInfo = `${bookFile}.i.json`;
|
||||
|
||||
let rows = await db.select({table: 'book', where: `@@hash('_uid', ${db.esc(bookUid)})`});
|
||||
@@ -501,7 +501,7 @@ class WebWorker {
|
||||
result.fb2 = fb2.rawNodes;
|
||||
|
||||
if (cover) {
|
||||
result.cover = `${this.config.filesPathStatic}/${hash}${coverExt}`;
|
||||
result.cover = `${this.config.bookPathStatic}/${hash}${coverExt}`;
|
||||
await fs.writeFile(`${bookFile}${coverExt}`, cover);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user