feat: walk al pack directories
parent
9ffb67ddff
commit
0beeb75cf0
|
@ -11,6 +11,37 @@ export default class PackService {
|
||||||
|
|
||||||
public static getInitialList = async () => {
|
public static getInitialList = async () => {
|
||||||
const packs = await fs.readdirSync(PACK_BASE_PATH);
|
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)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue