Работа над BookUpdateChecker
This commit is contained in:
@@ -229,6 +229,17 @@ class Reader {
|
||||
return (await axios.get(url)).data;
|
||||
}
|
||||
|
||||
async checkBuc(bookUrls) {
|
||||
const response = await wsc.message(await wsc.send({action: 'check-buc', bookUrls}));
|
||||
|
||||
if (response.error)
|
||||
throw new Error(response.error);
|
||||
|
||||
if (!response.data)
|
||||
throw new Error(`response.data is empty`);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export default new Reader();
|
||||
@@ -234,6 +234,10 @@ class BookManager {
|
||||
|
||||
async addBook(newBook, callback) {
|
||||
let meta = {url: newBook.url, path: newBook.path};
|
||||
|
||||
if (newBook.downloadSize !== undefined && newBook.downloadSize >= 0)
|
||||
meta.downloadSize = newBook.downloadSize;
|
||||
|
||||
meta.key = this.keyFromPath(meta.path);
|
||||
meta.addTime = Date.now();//время добавления в кеш
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class BUCClient {
|
||||
this.cleanQueryInterval = 300*dayMs;//интервал очистки устаревших
|
||||
this.syncPeriod = 1*hourMs;//период синхронизации с сервером BUC
|
||||
} else {
|
||||
this.cleanQueryInterval = 300*minuteMs;//300*dayMs;//интервал очистки устаревших
|
||||
this.cleanQueryInterval = 300*dayMs;//интервал очистки устаревших
|
||||
this.syncPeriod = 1*minuteMs;//период синхронизации с сервером BUC
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ class ReaderWorker {
|
||||
const tempFilename2 = utils.randomHexString(30);
|
||||
const decompDirname = utils.randomHexString(30);
|
||||
|
||||
let downloadSize = -1;
|
||||
//download or use uploaded
|
||||
if (url.indexOf('disk://') != 0) {//download
|
||||
const downdata = await this.down.load(url, (progress) => {
|
||||
@@ -112,6 +113,8 @@ class ReaderWorker {
|
||||
}, q.abort);
|
||||
|
||||
downloadedFilename = `${this.config.tempDownloadDir}/${tempFilename}`;
|
||||
|
||||
downloadSize = downdata.length;
|
||||
await fs.writeFile(downloadedFilename, downdata);
|
||||
} else {//uploaded file
|
||||
const fileHash = url.substr(7);
|
||||
@@ -166,7 +169,12 @@ class ReaderWorker {
|
||||
|
||||
//finish
|
||||
const finishFilename = path.basename(compFilename);
|
||||
wState.finish({path: `/tmp/${finishFilename}`, size: stat.size});
|
||||
|
||||
const result = {path: `/tmp/${finishFilename}`, size: stat.size};
|
||||
if (downloadSize >= 0)
|
||||
result.downloadSize = downloadSize;
|
||||
|
||||
wState.finish(result);
|
||||
|
||||
//асинхронно через 30 сек добавим в очередь на отправку
|
||||
//т.к. gzipFileIfNotExists может переупаковать файл
|
||||
|
||||
Reference in New Issue
Block a user