From c4c645437ffff8dcd0af93b09d143456fa441fc6 Mon Sep 17 00:00:00 2001 From: Andreas Schaafsma Date: Tue, 14 Jan 2025 02:41:08 +0100 Subject: [PATCH] update setupdb route --- src/app/api/setupDB/route.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/api/setupDB/route.ts b/src/app/api/setupDB/route.ts index 98618d7..40a6fea 100644 --- a/src/app/api/setupDB/route.ts +++ b/src/app/api/setupDB/route.ts @@ -24,7 +24,7 @@ import { SqliteQueryInterface, } from "@sequelize/sqlite3"; import { hashpassword } from "@/util/auth"; -import { copyFile, readFileSync } from "fs"; +import { copyFile, mkdirSync, readFileSync } from "fs"; import path from "path"; import { UUID } from "crypto"; import { runApiAction } from "@/util/api"; @@ -96,8 +96,10 @@ async function seedPosts(qif: SqliteQueryInterface) { bucket_id: bucket.id as UUID, filename: attachment.filename, }).then((a) => { + console.log(bucket.id); + mkdirSync(`./bucket/${bucket.id}/`, { recursive: true }); copyFile( - path.resolve(".", "db", "seed", "post", a.filename), + path.resolve(".", "db", "seed", "posts", a.filename), path.resolve(".", "bucket", bucket.id, a.filename), () => {} ); @@ -171,7 +173,7 @@ export async function GET(request: Request) { }); break; } - + console.log("pp"); return new Response( JSON.stringify({ test: await queryInterface.describeTable("Posts").then((t) => t),