| 827 | } |
| 828 | |
| 829 | async function boxes(path = false, mainPath = false) |
| 830 | { |
| 831 | if(path === false || path === mainPath) |
| 832 | { |
| 833 | const files = []; |
| 834 | |
| 835 | if(!path) |
| 836 | { |
| 837 | const opdsCatalogs = storage.get('opdsCatalogs'); |
| 838 | |
| 839 | for(const key in opdsCatalogs) |
| 840 | { |
| 841 | files.push(...Object.values(opdsCatalogs[key].downloadFiles ?? {})); |
| 842 | } |
| 843 | } |
| 844 | else |
| 845 | { |
| 846 | files.push(...Object.values(currentCatalog.downloadFiles ?? {})); |
| 847 | } |
| 848 | |
| 849 | const comics = []; |
| 850 | |
| 851 | for(let i = 0, len = files.length; i < len; i++) |
| 852 | { |
| 853 | const path = files[i]; |
| 854 | |
| 855 | if(fs.existsSync(path)) |
| 856 | { |
| 857 | const stat = fs.statSync(path); |
| 858 | const compressed = fileManager.isCompressed(path); |
| 859 | |
| 860 | const name = dom.metadataPathName({ |
| 861 | name: p.basename(path), |
| 862 | path: path, |
| 863 | compressed: compressed, |
| 864 | }); |
| 865 | |
| 866 | comics.push({ |
| 867 | name: name, |
| 868 | path: path, |
| 869 | added: Math.round(stat.ctimeMs / 1000), |
| 870 | folder: true, |
| 871 | compressed: compressed, |
| 872 | }); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | const len = comics.length; |
| 877 | |
| 878 | if(len) |
| 879 | { |
| 880 | // Comic reading progress |
| 881 | let readingProgress = relative.get('readingProgress'); |
| 882 | |
| 883 | for(let i = 0; i < len; i++) |
| 884 | { |
| 885 | comics[i].readingProgress = readingProgress[comics[i].path] || {lastReading: 0}; |
| 886 | } |