diff --git a/src/services/pack_service.ts b/src/services/pack_service.ts index 62bca66..b2b5331 100644 --- a/src/services/pack_service.ts +++ b/src/services/pack_service.ts @@ -11,6 +11,37 @@ export default class PackService { public static getInitialList = async () => { const packs = await fs.readdirSync(PACK_BASE_PATH); - packs.forEach((pack) => {}); + + // Setup walk + const noDots = (entry: fsWalk.Entry) => !entry.path.startsWith("."); + packs.forEach(async (pack) => { + const name = pack; + let size = 0; + let bpm: string = ""; + const packFiles = await fsWalk.walkSync(`${PACK_BASE_PATH}/${pack}`, { + entryFilter: noDots, + concurrency: 4, + }); + + packFiles.forEach(async (file) => { + size += await fs.statSync(file.path).size; + if (file.name === "bpm.txt") { + bpm = await fs.readFileSync(file.path).toString(); + } + }); + const currentPack: Pack = { + name: name, + size: size, + bpm: bpm, + }; + console.log(currentPack); + if (currentPack.bpm !== '') { + PackService.packList.push(currentPack); + } else { + console.log('found corrupted pack', currentPack.name) + } + }); + + }; }