Replace timestamp-based IDs with UUIDs for guaranteed uniqueness and race condition safety
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { randomUUID } from 'crypto'
|
||||
|
||||
// Handle both dev and production paths
|
||||
const getDataPath = (filename) => {
|
||||
@@ -75,10 +76,10 @@ export async function saveMember(memberData) {
|
||||
throw new Error('Mitglied nicht gefunden')
|
||||
}
|
||||
} else {
|
||||
// Add new
|
||||
// Add new - use UUID for guaranteed uniqueness
|
||||
const newMember = {
|
||||
id: `m${Date.now()}`,
|
||||
...memberData
|
||||
...memberData,
|
||||
id: randomUUID() // Cryptographically secure unique ID
|
||||
}
|
||||
members.push(newMember)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user