diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue
index 4fd3b7a8..1b8a0afb 100644
--- a/client/components/Reader/Reader.vue
+++ b/client/components/Reader/Reader.vue
@@ -573,14 +573,28 @@ class Reader {
//теперь по кусочкам запросим сервер
const arr = Array.from(updateUrls);
+ const bucSize = {};
const chunkSize = 100;
for (let i = 0; i < arr.length; i += chunkSize) {
const chunk = arr.slice(i, i + chunkSize);
const data = await readerApi.checkBuc(chunk);
-console.log(data);
+
+ for (const item of data) {
+ bucSize[item.id] = item.size;
+ }
+
await utils.sleep(1000);//чтобы не ддосить сервер
}
+
+ //проставим новые размеры у книг
+ for (const book of sorted) {
+ //размер 0 считаем отсутствующим
+ if (book.url && bucSize[book.url] && bucSize[book.url] !== book.bucSize) {
+ book.bucSize = bucSize[book.url];
+ await bookManager.recentSetItem(book);
+ }
+ }
console.log('checkBuc finished', arr);
} catch (e) {
console.error(e);
diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue
index 6687ee26..6cddbc74 100644
--- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue
+++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue
@@ -126,6 +126,9 @@
{{ item.desc.title }}
+
+ Старый размер: {{ item.bucSize }}, новый: {{ item.downloadSize }}
+
@@ -169,7 +172,7 @@
class="col column justify-center"
style="font-size: 75%; padding-left: 6px; border: 1px solid #cccccc; border-left: 0;"
>
-
+
@@ -195,6 +198,22 @@
Восстановить из архива
+
+
+
+
+ Проверять обновления
+
+
+
@@ -240,6 +259,10 @@ class RecentBooksPage {
tableData = [];
sortMethod = '';
showSameBook = false;
+ bucEnabled = false;
+ bucSizeDiff = 0;
+ bucSetOnNew = false;
+
archive = false;
covers = {};
@@ -277,12 +300,19 @@ class RecentBooksPage {
const settings = this.settings;
this.showSameBook = settings.recentShowSameBook;
this.sortMethod = settings.recentSortMethod || 'loadTimeDesc';
+ this.bucEnabled = settings.bucEnabled;
+ this.bucSizeDiff = settings.bucSizeDiff;
+ this.bucSetOnNew = settings.bucSetOnNew;
}
get settings() {
return this.$store.state.reader.settings;
}
+ get bothBucEnabled() {
+ return this.$store.state.config.bucEnabled && this.bucEnabled;
+ }
+
async updateTableData() {
if (!this.inited)
return;
@@ -344,6 +374,12 @@ class RecentBooksPage {
inGroup: false,
coverPageUrl: book.coverPageUrl,
+ showCheckBuc: !this.archive && utils.hasProp(book, 'downloadSize'),
+ checkBuc: !!book.checkBuc,
+ needBookUpdate: (!this.archive && book.checkBuc && book.bucSize && utils.hasProp(book, 'downloadSize') && (book.bucSize - book.downloadSize >= this.bucSizeDiff)),
+ bucSize: book.bucSize,
+ downloadSize: book.downloadSize,
+
//для сортировки
loadTimeRaw,
touchTimeRaw: book.touchTime,
@@ -713,6 +749,14 @@ class RecentBooksPage {
else
return '';
}
+
+ async checkBucChange(item) {
+ const book = await bookManager.getRecentBook(item);
+ if (book) {
+ book.checkBuc = item.checkBuc;
+ await bookManager.recentSetItem(book);
+ }
+ }
}
export default vueComponent(RecentBooksPage);
@@ -855,4 +899,8 @@ export default vueComponent(RecentBooksPage);
.header-button-pressed:hover {
color: black;
}
+
+.buc-checkbox {
+ position: absolute;
+}
diff --git a/client/components/Reader/share/bookManager.js b/client/components/Reader/share/bookManager.js
index f8f9fdde..62715649 100644
--- a/client/components/Reader/share/bookManager.js
+++ b/client/components/Reader/share/bookManager.js
@@ -237,7 +237,7 @@ class BookManager {
if (newBook.downloadSize !== undefined && newBook.downloadSize >= 0)
meta.downloadSize = newBook.downloadSize;
-
+
meta.key = this.keyFromPath(meta.path);
meta.addTime = Date.now();//время добавления в кеш
diff --git a/server/core/BookUpdateChecker/BUCClient.js b/server/core/BookUpdateChecker/BUCClient.js
index 099cb9fe..54688c33 100644
--- a/server/core/BookUpdateChecker/BUCClient.js
+++ b/server/core/BookUpdateChecker/BUCClient.js
@@ -78,7 +78,8 @@ class BUCClient {
const rows = await db.select({
table: 'buc',
- where: `@@id(${db.esc(bookUrls)})`
+ map: `(r) => ({id: r.id, size: r.size})`,
+ where: `@@id(${db.esc(bookUrls)})`,
});
return rows;