MCPcopy
hub / github.com/codedogQBY/ReadAny / buildDownloadCoverTask

Function buildDownloadCoverTask

packages/core/src/sync/sync-files.ts:1046–1071  ·  view source on GitHub ↗
(backend: ISyncBackend, info: BookInfo)

Source from the content-addressed store, hash-verified

1044}
1045
1046function buildDownloadCoverTask(backend: ISyncBackend, info: BookInfo): FileTask {
1047 const bookTitle = info.book.title || "未知书籍";
1048 return {
1049 label: `${bookTitle} cover`,
1050 run: async (onProgress) => {
1051 const taskStart = Date.now();
1052 try {
1053 console.log(`[Sync] 📥 Downloading cover: ${bookTitle} ← ${info.remoteCoverPath}`);
1054 const bytes = await downloadRemoteFileToPath(
1055 backend,
1056 info.remoteCoverPath,
1057 info.localCoverPath,
1058 onProgress,
1059 );
1060 const size = bytes === null ? "" : ` (${(bytes / 1024).toFixed(2)} KB)`;
1061 console.log(
1062 `[Sync] ✓ Downloaded cover "${bookTitle}"${size} in ${Date.now() - taskStart}ms`,
1063 );
1064 return true;
1065 } catch (e) {
1066 console.log(`[Sync] ✗ Failed to download cover "${bookTitle}": ${e}`);
1067 return false;
1068 }
1069 },
1070 };
1071}
1072
1073async function cleanupRemoteOrphans(
1074 backend: ISyncBackend,

Callers 1

syncFilesFunction · 0.85

Calls 1

downloadRemoteFileToPathFunction · 0.85

Tested by

no test coverage detected