Fixed type definition of SongCursorInfos fixed 'race conditions' in asset generation service removed hard coded cursor infos fixed tsc looking to build folders

This commit is contained in:
Clément Le Bihan
2023-11-06 12:00:16 +01:00
parent 4a5658c4ca
commit f1662ca18b
7 changed files with 127 additions and 8499 deletions

View File

@@ -157,12 +157,6 @@ export async function generateSongAssets(
eval(`import("cross-blob")`).then((module) => {
Blob = module.default;
});
try {
let e = require("canvas")
console.log(e, "pass");
} catch (e) {
console.log(e);
}
debug("" + sampleDir + " " + imageDir + " " + imageFormat);
if (!mode) {

View File

@@ -5,12 +5,24 @@ import { generateSongAssets } from "src/assetsgenerator/generateImages_browserle
@Injectable()
export class SongService {
constructor(private prisma: PrismaService) {}
// number is the song id
private readonly assetCreationTasks: Map<number, Promise<void>>;
constructor(private prisma: PrismaService) {
this.assetCreationTasks = new Map();
}
async createAssets(mxlPath: string, songId: number): Promise<void> {
if (this.assetCreationTasks.has(songId)) {
await this.assetCreationTasks.get(songId);
this.assetCreationTasks.delete(songId);
return;
}
// mxlPath can the path to an archive to an xml file or the path to the xml file directly
// const generateSongAssets = (await import("src/assetsgenerator/generateImages_browserless.mjs")).default;
return generateSongAssets(songId, mxlPath, "/data/cache/songs", "svg");
this.assetCreationTasks.set(
songId,
generateSongAssets(songId, mxlPath, "/data/cache/songs", "svg"),
);
return await this.assetCreationTasks.get(songId);
}
async songByArtist(data: number): Promise<Song[]> {