Skip to content

Commit af623bb

Browse files
committed
Don't attempt to start gameserver if no file exists
1 parent 49bfb9b commit af623bb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Site/src/routes/(main)/place/[id=asset]/[name]/+page.server.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from "node:fs"
12
import { error, redirect } from "@sveltejs/kit"
23
import { authorise } from "$lib/server/auth"
34
import config from "$lib/server/config"
@@ -125,13 +126,19 @@ actions.join = async ({ locals, params, request }) => {
125126
return { ticket }
126127
}
127128

128-
actions.start = async ({ locals, params, getClientAddress }) => {
129-
await checkUser(locals)
129+
actions.start = async ({ locals, params, request, getClientAddress }) => {
130+
const user = await checkUser(locals)
130131

131132
const limit = ratelimit(null, "serverstart", getClientAddress, 20)
132133
if (limit) return limit
133134

134135
const id = +params.id
136+
await findPlace(request, id, user)
137+
138+
// check for existence of a place file
139+
const placeFile = `../data/places/${id}`
140+
if (!fs.existsSync(placeFile)) error(404, "Place file not found")
141+
135142
const res = await startGameserver(id)
136143
if (!res.ok) {
137144
console.error(

0 commit comments

Comments
 (0)