fix: books without cover images now can be synced across devices (#878)

This commit is contained in:
Huang Xin
2025-04-13 16:47:50 +08:00
committed by GitHub
parent f004d7b3ea
commit ee6500cecb
22 changed files with 60 additions and 32 deletions
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "جارٍ تنزيل {{downloaded}} من {{contentLength}}",
"Download finished": "اكتمل التنزيل",
"DOWNLOAD & INSTALL": "تنزيل وتثبيت",
"Changelog:": "سجل التغييرات:"
"Changelog:": "سجل التغييرات:",
"Redownload": "إعادة التنزيل"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Herunterladen {{downloaded}} von {{contentLength}}",
"Download finished": "Download abgeschlossen",
"DOWNLOAD & INSTALL": "HERUNTERLADEN & INSTALLIEREN",
"Changelog:": "Änderungsprotokoll:"
"Changelog:": "Änderungsprotokoll:",
"Redownload": "Neu herunterladen"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Κατεβάζω {{downloaded}} από {{contentLength}}",
"Download finished": "Η λήψη ολοκληρώθηκε",
"DOWNLOAD & INSTALL": "ΛΗΨΗ & ΕΓΚΑΤΑΣΤΑΣΗ",
"Changelog:": "Αλλαγές:"
"Changelog:": "Αλλαγές:",
"Redownload": "Επαναφόρτωση"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Descargando {{downloaded}} de {{contentLength}}",
"Download finished": "Descarga finalizada",
"DOWNLOAD & INSTALL": "DESCARGAR E INSTALAR",
"Changelog:": "Notas de la versión:"
"Changelog:": "Notas de la versión:",
"Redownload": "Volver a descargar"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Téléchargement {{downloaded}} sur {{contentLength}}",
"Download finished": "Téléchargement terminé",
"DOWNLOAD & INSTALL": "TÉLÉCHARGER ET INSTALLER",
"Changelog:": "Journal des modifications :"
"Changelog:": "Journal des modifications :",
"Redownload": "Télécharger à nouveau"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "डाउनलोड कर रहा है {{downloaded}} का {{contentLength}}",
"Download finished": "डाउनलोड पूरा हुआ",
"DOWNLOAD & INSTALL": "डाउनलोड और इंस्टॉल करें",
"Changelog:": "चेंजलॉग:"
"Changelog:": "चेंजलॉग:",
"Redownload": "री-डाउनलोड करें"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Mengunduh {{downloaded}} dari {{contentLength}}",
"Download finished": "Unduhan selesai",
"DOWNLOAD & INSTALL": "UNDUH & INSTAL",
"Changelog:": "Catatan Perubahan:"
"Changelog:": "Catatan Perubahan:",
"Redownload": "Unduh Ulang"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Scaricando {{downloaded}} di {{contentLength}}",
"Download finished": "Download completato",
"DOWNLOAD & INSTALL": "SCARICA E INSTALLA",
"Changelog:": "Note di rilascio:"
"Changelog:": "Note di rilascio:",
"Redownload": "Scarica di nuovo"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "ダウンロード中 {{downloaded}} / {{contentLength}}",
"Download finished": "ダウンロード完了",
"DOWNLOAD & INSTALL": "更新",
"Changelog:": "変更ログ:"
"Changelog:": "変更ログ:",
"Redownload": "再ダウンロード"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "다운로드 중 {{downloaded}} / {{contentLength}}",
"Download finished": "다운로드 완료",
"DOWNLOAD & INSTALL": "다운로드 및 설치",
"Changelog:": "변경 로그:"
"Changelog:": "변경 로그:",
"Redownload": "다시 다운로드"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Pobieranie {{downloaded}} z {{contentLength}}",
"Download finished": "Pobieranie zakończone",
"DOWNLOAD & INSTALL": "POBIERZ I ZAINSTALUJ",
"Changelog:": "Dziennik zmian:"
"Changelog:": "Dziennik zmian:",
"Redownload": "Pobierz ponownie"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Baixando {{downloaded}} de {{contentLength}}",
"Download finished": "Download concluído",
"DOWNLOAD & INSTALL": "BAIXAR E INSTALAR",
"Changelog:": "Notas de versão:"
"Changelog:": "Notas de versão:",
"Redownload": "Baixar novamente"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Скачано {{downloaded}} из {{contentLength}}",
"Download finished": "Загрузка завершена",
"DOWNLOAD & INSTALL": "СКАЧАТЬ И УСТАНОВИТЬ",
"Changelog:": "Изменения:"
"Changelog:": "Изменения:",
"Redownload": "Переустановить"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "İndiriliyor {{downloaded}}/{{contentLength}}",
"Download finished": "İndirme tamamlandı",
"DOWNLOAD & INSTALL": "İNDİR & YÜKLE",
"Changelog:": "Değişiklik Günlüğü:"
"Changelog:": "Değişiklik Günlüğü:",
"Redownload": "Yeniden İndir"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Завантаження {{downloaded}} з {{contentLength}}",
"Download finished": "Завантаження завершено",
"DOWNLOAD & INSTALL": "ЗАВАНТАЖИТИ І ВСТАНОВИТИ",
"Changelog:": "Журнал змін:"
"Changelog:": "Журнал змін:",
"Redownload": "Завантажити знову"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "Đang tải {{downloaded}} trong {{contentLength}}",
"Download finished": "Tải xuống hoàn tất",
"DOWNLOAD & INSTALL": "TẢI XUỐNG & CÀI ĐẶT",
"Changelog:": "Thay đổi:"
"Changelog:": "Thay đổi:",
"Redownload": "Tải lại"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "正在下载 {{downloaded}} / {{contentLength}}",
"Download finished": "下载完成",
"DOWNLOAD & INSTALL": "下载并安装",
"Changelog:": "更新日志:"
"Changelog:": "更新日志:",
"Redownload": "重新下载"
}
@@ -281,5 +281,6 @@
"Downloading {{downloaded}} of {{contentLength}}": "正在下載 {{downloaded}} / {{contentLength}}",
"Download finished": "下載完成",
"DOWNLOAD & INSTALL": "下載並安裝",
"Changelog:": "更新日誌:"
"Changelog:": "更新日誌:",
"Redownload": "重新下載"
}
@@ -98,11 +98,12 @@ export const useBooksSync = ({ onSyncStart, onSyncEnd }: UseBooksSyncProps) => {
if (newBook.uploadedAt && !newBook.deletedAt) {
try {
await appService?.downloadBook(newBook, true);
} catch {
console.error('Failed to download book:', newBook);
} finally {
newBook.coverImageUrl = await appService?.generateCoverImageUrl(newBook);
updatedLibrary.push(newBook);
setLibrary(updatedLibrary);
} catch {
console.error('Failed to download book:', newBook);
}
}
}
@@ -129,9 +129,11 @@ const BookDetailModal = ({ book, isOpen, onClose }: BookDetailModalProps) => {
>
{_('Delete')}
</button>
<button className='btn btn-disabled bg-primary/25 hover:bg-primary/85 rounded-xl px-4 text-white'>
{_('More Info')}
</button>
{book.uploadedAt && (
<button className='btn rounded-xl bg-orange-500 text-white hover:bg-orange-600'>
{_('Redownload')}
</button>
)}
</div>
)}
</div>
@@ -145,9 +147,11 @@ const BookDetailModal = ({ book, isOpen, onClose }: BookDetailModalProps) => {
>
{_('Delete')}
</button>
<button className='btn btn-disabled bg-primary/25 hover:bg-primary/85 rounded px-4 text-white'>
{_('More Info')}
</button>
{book.uploadedAt && (
<button className='btn rounded bg-orange-500 text-white hover:bg-orange-600'>
{_('Redownload')}
</button>
)}
</div>
)}
+1 -1
View File
@@ -97,7 +97,7 @@ export const downloadFile = async (
return;
}
} catch (error) {
console.error('File download failed:', error);
console.error(`File '${filePath}' download failed:`, error);
throw new Error('File download failed');
}
};
+10 -5
View File
@@ -375,11 +375,16 @@ export abstract class BaseAppService implements AppService {
await this.fs.createDir(getDir(book), 'Books');
}
if (needDownCover) {
const lfp = getCoverFilename(book);
const cfp = `${CLOUD_BOOKS_SUBDIR}/${lfp}`;
await this.downloadCloudFile(lfp, cfp, handleProgress);
completedFiles.count++;
try {
if (needDownCover) {
const lfp = getCoverFilename(book);
const cfp = `${CLOUD_BOOKS_SUBDIR}/${lfp}`;
await this.downloadCloudFile(lfp, cfp, handleProgress);
completedFiles.count++;
}
} catch (error) {
// don't throw error here since some books may not have cover images at all
console.log('Failed to download cover file:', error);
}
if (needDownBook) {