Use sync access for the temp JSON file database
Replace all async reads and writes to the JSON database with the sync reads and writes to prevent a data corruption race condition where two requests are processed at the same time and write to the same file, or one reads while the other writes causing read of partially written data.
This commit is contained in:
parent
f9d188b2ba
commit
80cec71308
23 changed files with 138 additions and 138 deletions
|
@ -13,7 +13,7 @@ const detailsSchema = z.object({
|
|||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireServerSessionWithAdmin(event);
|
||||
const users = await readUsers();
|
||||
const users = readUsers();
|
||||
const { success, error, data: params } = detailsSchema.safeParse(getRouterParams(event));
|
||||
if (!success) {
|
||||
throw createError({
|
||||
|
|
|
@ -6,7 +6,7 @@ import { readUsers } from "~/server/database"
|
|||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await requireServerSessionWithUser(event);
|
||||
const users = await readUsers();
|
||||
const users = readUsers();
|
||||
|
||||
if (session.access === "admin") {
|
||||
return users.map(serverUserToApi);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue