Commit 98e407e
fix(storage): validate fileIds, batch deletions, correct test comment
Three review fixes on the orphan-delete path:
- Validate every entry in the request's `fileIds` array against the
same `^[\w-]{1,200}$` regex used elsewhere. Without this, a non-
string or path-traversal-shaped id slipped past the array-shape
check and would only blow up inside the Prisma / S3 calls below.
- Batch the cleanup. The previous loop did per-file
`s3File.findUnique` + `deleteS3Object` + `s3File.delete` serially.
For large selections that's N+1 round trips and a stalled HTTP
request. Use a single `findMany` keyed by the fileId set, parallel
S3 deletes (concurrency 8) with `Promise.allSettled` so one S3
failure doesn't drop subsequent deletions, and a single
`deleteMany` for the rows.
- The diff test's `totalCanvasRefs: 2` came with the comment "active
only", but the route counts every canvas-referenced fileId
including soft-deleted ones (`file-a` active + `file-b` deleted).
Fix the comment so it documents the real semantic.
Change-Id: Id61e9a2d6f17ccc6e6c8922e6b8e6549b32c73f4
Co-developed-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0013d80 commit 98e407e
2 files changed
Lines changed: 67 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
324 | 328 | | |
325 | | - | |
| 329 | + | |
326 | 330 | | |
327 | 331 | | |
328 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
| 320 | + | |
321 | 321 | | |
322 | | - | |
| 322 | + | |
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
326 | 342 | | |
327 | 343 | | |
328 | 344 | | |
| |||
341 | 357 | | |
342 | 358 | | |
343 | 359 | | |
344 | | - | |
345 | | - | |
346 | | - | |
| 360 | + | |
347 | 361 | | |
348 | 362 | | |
349 | 363 | | |
350 | 364 | | |
351 | 365 | | |
352 | 366 | | |
353 | 367 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
373 | 376 | | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
380 | 387 | | |
381 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
382 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
383 | 412 | | |
| 413 | + | |
| 414 | + | |
384 | 415 | | |
385 | 416 | | |
386 | 417 | | |
| |||
0 commit comments