fix: AI photo enhance modal stays open with result preview; fix basicsr build

- Modal no longer auto-closes after Real-ESRGAN completes; result loads into
  canvas so user can review, adjust sliders, and choose to apply or discard
- Backend skips swapEntryPhotoFiles until user confirms via Применить
- New DELETE /api/entries/:id/photo/enhance-ai/preview for temp file cleanup
- photo-ai Dockerfile: patch basicsr via find+sed instead of import (avoids
  torchvision.functional_tensor import crash)
This commit is contained in:
dev
2026-09-17 16:44:44 +03:00
parent 3a345cbefd
commit dec8790a3a
3 changed files with 52 additions and 14 deletions
+7 -1
View File
@@ -3789,7 +3789,6 @@ async function runPhotoAiJob(job) {
const out = Buffer.from(await resp.arrayBuffer());
const newName = crypto.randomBytes(12).toString('hex') + '.jpg';
fs.writeFileSync(path.join(UPLOADS_DIR, newName), out);
await swapEntryPhotoFiles(job.req, job.entryId, photoPath, `/uploads/${newName}`);
job.photo_path = `/uploads/${newName}`;
job.status = 'done';
} catch (e) {
@@ -3834,6 +3833,13 @@ app.get('/api/entries/:id/photo/enhance-ai/:jobId', requireAuth, async (req, res
res.json(out);
});
app.delete('/api/entries/:id/photo/enhance-ai/preview', requireAuth, async (req, res) => {
const { path: p } = req.body || {};
if (!isSafeUploadPath(p)) return res.status(400).json({ error: 'Некорректный путь' });
safeUnlink(p);
res.json({ ok: true });
});
app.post('/api/entries/:id/photo/restore-original', requireAuth, async (req, res) => {
if (req.user.role !== 'admin') {
const acc = await entryAccessible(req.user, req.params.id);