fix: images, couverture, slash, agents, wizard, Stripe et admin
- Collage/accès images: ownership path userId + meta legacy, 403 non caché - Couverture note: explicite (choix/aucune), plus d’auto depuis le corps - Éditeur: suppression image TipTap, sync immédiate, toolbar réordonnée - Slash: listes par titre (plus d’index), keywords nettoyés - Agents: nextRun à la réactivation, cron sans stampede null - Wizard: titres courts + mode Expert plus robuste - Stripe checkout hosted fiable; admin métriques live; dark mode IA/settings - Indexation notes courtes + test unit aligné
This commit is contained in:
@@ -20,14 +20,26 @@ export async function deleteImageFileSafely(imageUrl: string, excludeNoteId?: st
|
||||
|
||||
try {
|
||||
const notes = await prisma.note.findMany({
|
||||
where: { images: { contains: imageUrl } },
|
||||
where: {
|
||||
OR: [
|
||||
{ images: { contains: imageUrl } },
|
||||
{ content: { contains: imageUrl } },
|
||||
],
|
||||
},
|
||||
select: { id: true },
|
||||
})
|
||||
const otherRefs = notes.filter(n => n.id !== excludeNoteId)
|
||||
if (otherRefs.length > 0) return // File still referenced elsewhere
|
||||
|
||||
const filePath = path.join(process.cwd(), 'data', imageUrl)
|
||||
// imageUrl = /uploads/notes/... → data/uploads/notes/...
|
||||
const filePath = path.join(process.cwd(), 'data', imageUrl.replace(/^\//, ''))
|
||||
await fs.unlink(filePath)
|
||||
// Remove ownership sidecar if present
|
||||
try {
|
||||
await fs.unlink(filePath + '.meta.json')
|
||||
} catch {
|
||||
/* no meta */
|
||||
}
|
||||
} catch {
|
||||
// File already gone or unreadable -- silently skip
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user