{{ props.message }}
@@ -11,5 +14,6 @@
diff --git a/package.json b/package.json
index a199e03..7e312a9 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,6 @@
"nuxt": "^3.16.2",
"nuxt-security": "2.2.0",
"prisma": "^6.5.0",
- "sanitize-filename": "^1.6.3",
"sharp": "^0.33.5",
"stream-mime-type": "^2.0.0",
"turndown": "^7.2.0",
diff --git a/prisma/migrations/20250414002714_add_object_hash/migration.sql b/prisma/migrations/20250414002714_add_object_hash/migration.sql
new file mode 100644
index 0000000..b0c17b0
--- /dev/null
+++ b/prisma/migrations/20250414002714_add_object_hash/migration.sql
@@ -0,0 +1,7 @@
+-- CreateTable
+CREATE TABLE "ObjectHash" (
+ "id" TEXT NOT NULL,
+ "hash" TEXT NOT NULL,
+
+ CONSTRAINT "ObjectHash_pkey" PRIMARY KEY ("id")
+);
diff --git a/server/api/v1/admin/game/image/index.delete.ts b/server/api/v1/admin/game/image/index.delete.ts
index 3d3440e..2751d31 100644
--- a/server/api/v1/admin/game/image/index.delete.ts
+++ b/server/api/v1/admin/game/image/index.delete.ts
@@ -35,7 +35,7 @@ export default defineEventHandler(async (h3) => {
throw createError({ statusCode: 400, statusMessage: "Image not found" });
game.mImageLibrary.splice(imageIndex, 1);
- await objectHandler.deleteAsServer(imageId);
+ await objectHandler.deleteAsSystem(imageId);
if (game.mBannerId === imageId) {
game.mBannerId = game.mImageLibrary[0];
diff --git a/server/api/v1/object/[id]/index.get.ts b/server/api/v1/object/[id]/index.get.ts
index cfd6979..1b93c9c 100644
--- a/server/api/v1/object/[id]/index.get.ts
+++ b/server/api/v1/object/[id]/index.get.ts
@@ -13,11 +13,12 @@ export default defineEventHandler(async (h3) => {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag
const etagRequestValue = h3.headers.get("If-None-Match");
- const etagActualValue = await objectHandler.fetchHashWithWithPermissions(
- id,
- userId
- );
- if (etagRequestValue !== null && etagActualValue === etagRequestValue) {
+ const etagActualValue = await objectHandler.fetchHash(id);
+ if (
+ etagRequestValue &&
+ etagActualValue &&
+ etagActualValue === etagRequestValue
+ ) {
// would compare if etag is valid, but objects should never change
setResponseStatus(h3, 304);
return null;
diff --git a/server/api/v1/object/[id]/index.head.ts b/server/api/v1/object/[id]/index.head.ts
index a1e9b51..b3f836e 100644
--- a/server/api/v1/object/[id]/index.head.ts
+++ b/server/api/v1/object/[id]/index.head.ts
@@ -14,10 +14,7 @@ export default defineEventHandler(async (h3) => {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag
const etagRequestValue = h3.headers.get("If-None-Match");
- const etagActualValue = await objectHandler.fetchHashWithWithPermissions(
- id,
- userId
- );
+ const etagActualValue = await objectHandler.fetchHash(id);
if (etagRequestValue !== null && etagActualValue === etagRequestValue) {
// would compare if etag is valid, but objects should never change
setResponseStatus(h3, 304);
diff --git a/server/internal/news/index.ts b/server/internal/news/index.ts
index 603a077..38b3cec 100644
--- a/server/internal/news/index.ts
+++ b/server/internal/news/index.ts
@@ -129,7 +129,7 @@ class NewsManager {
where: { id },
});
if (article.image) {
- return await objectHandler.deleteAsServer(article.image);
+ return await objectHandler.deleteAsSystem(article.image);
}
return true;
}
diff --git a/server/internal/objects/fsBackend.ts b/server/internal/objects/fsBackend.ts
index 428f62a..13ad2b9 100644
--- a/server/internal/objects/fsBackend.ts
+++ b/server/internal/objects/fsBackend.ts
@@ -5,7 +5,6 @@ import {
Source,
} from "./objectHandler";
-import sanitize from "sanitize-filename";
import { LRUCache } from "lru-cache";
import fs from "fs";
import path from "path";
@@ -30,12 +29,13 @@ export class FsObjectBackend extends ObjectBackend {
}
async fetch(id: ObjectReference) {
- const objectPath = path.join(this.baseObjectPath, sanitize(id));
+ console.log("ID: " + id);
+ const objectPath = path.join(this.baseObjectPath, id);
if (!fs.existsSync(objectPath)) return undefined;
return fs.createReadStream(objectPath);
}
async write(id: ObjectReference, source: Source): Promise