From f98b811ab99b9198a3c44fa216b8ee09edc9fab3 Mon Sep 17 00:00:00 2001 From: FurbyOnSteroids Date: Sat, 16 Aug 2025 13:53:56 +0200 Subject: [PATCH] replace buffer implementation with a md5 hash. This also adds the ts-md5 library. --- package.json | 3 ++- server/internal/library/index.ts | 9 +++------ yarn.lock | 5 +++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 3a68d92..970043f 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "vue-router": "latest", "vue3-carousel": "^0.16.0", "vue3-carousel-nuxt": "^1.1.5", - "vuedraggable": "^4.1.0" + "vuedraggable": "^4.1.0", + "ts-md5": "^2.0.1" }, "devDependencies": { "@intlify/eslint-plugin-vue-i18n": "^4.0.1", diff --git a/server/internal/library/index.ts b/server/internal/library/index.ts index f74d663..b3e2c71 100644 --- a/server/internal/library/index.ts +++ b/server/internal/library/index.ts @@ -14,17 +14,14 @@ import notificationSystem from "../notifications"; import { GameNotFoundError, type LibraryProvider } from "./provider"; import { logger } from "../logging"; import type { GameModel } from "~/prisma/client/models"; +import { Md5 } from "ts-md5"; export function createGameImportTaskId(libraryId: string, libraryPath: string) { - const text = `import:${libraryId}:${libraryPath}`; - // base64 can contain "/" which breaks the URL. So we remove it - return Buffer.from(text, "utf8").toString("base64").replaceAll("/", ""); + return Md5.hashStr(`import:${libraryId}:${libraryPath}`); } export function createVersionImportTaskId(gameId: string, versionName: string) { - const text = `import:${gameId}:${versionName}`; - // base64 can contain "/" which breaks the URL. So we remove it - return Buffer.from(text, "utf8").toString("base64").replaceAll("/", ""); + return Md5.hashStr(`import:${gameId}:${versionName}`); } class LibraryManager { diff --git a/yarn.lock b/yarn.lock index 7d3f9a9..d9d66c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8652,6 +8652,11 @@ ts-api-utils@^2.1.0: resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-2.1.0.tgz#595f7094e46eed364c13fd23e75f9513d29baf91" integrity sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ== +ts-md5@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/ts-md5/-/ts-md5-2.0.1.tgz#b05fb6d65f2116aa4591280c8d0510084567f291" + integrity sha512-yF35FCoEOFBzOclSkMNEUbFQZuv89KEQ+5Xz03HrMSGUGB1+r+El+JiGOFwsP4p9RFNzwlrydYoTLvPOuICl9w== + tslib@^2.4.0, tslib@^2.6.3, tslib@^2.8.0, tslib@^2.8.1: version "2.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"