MCPcopy
hub / github.com/ollm/OpenComic / getFolderThumbnails

Function getFolderThumbnails

scripts/dom.js:1512–1591  ·  view source on GitHub ↗
(path, forceSize = false, index = 0, start = 0, end = 99999)

Source from the content-addressed store, hash-verified

1510}
1511
1512async function getFolderThumbnails(path, forceSize = false, index = 0, start = 0, end = 99999)
1513{
1514 const getProgress = handlebarsContext.page.fadeCompleted || handlebarsContext.page.progressBar || handlebarsContext.page.progressPages || handlebarsContext.page.progressPercent;
1515 const folderSha = sha1(path+(forceSize ? '?size='+forceSize : ''));
1516
1517 let poster = {cache: false, path: '', sha: folderSha+'-0'};
1518
1519 let images = [
1520 {cache: false, path: '', sha: folderSha+'-0'},
1521 {cache: false, path: '', sha: folderSha+'-1'},
1522 {cache: false, path: '', sha: folderSha+'-2'},
1523 {cache: false, path: '', sha: folderSha+'-3'},
1524 ];
1525
1526 let progress = false;
1527
1528 let addToQueue = false;
1529 let addToQueueProgress = false;
1530
1531 if(index >= start && index <= end)
1532 {
1533 try
1534 {
1535 let file = fileManager.file(path, {fromThumbnailsGeneration: true, subtask: true});
1536 file.updateConfig({cacheOnly: true});
1537 let _images = await file.images(4, false, true);
1538
1539 _images = await _getFolderThumbnails(file, images, _images, path, folderSha, false, forceSize);
1540
1541 file.destroy();
1542
1543 poster = _images.poster;
1544 images = _images.poster ? false : _images.images;
1545 }
1546 catch(error)
1547 {
1548 if(error.message && /notCacheOnly/.test(error.message))
1549 {
1550 addToQueue = 1;
1551 }
1552 else
1553 {
1554 console.error(error);
1555
1556 dom.compressedError(error, false);
1557 fileManager.requestFileAccess.check(path, error);
1558 }
1559 }
1560
1561 try
1562 {
1563 if(getProgress)
1564 progress = await reading.progress.get(path, true, true);
1565 }
1566 catch(error)
1567 {
1568 if(error.message && /notCacheOnly/.test(error.message))
1569 addToQueueProgress = 1;

Callers 2

loadFilesIndexPageFunction · 0.85
loadIndexPageFunction · 0.85

Calls 2

sha1Function · 0.85
_getFolderThumbnailsFunction · 0.85

Tested by

no test coverage detected