Corrigir ícones e adicionar exclusão no explorador de arquivos
- Trocar ícone archive (lixeira) por download em todos os botões - Adicionar botão de excluir com ícone trash-2 em cada entrada - Rota DELETE /api/files com proteção contra exclusão da raiz - Confirmação via modal antes de excluir
This commit is contained in:
@@ -11,7 +11,7 @@ import * as pipeline from '../agents/pipeline.js';
|
||||
import { getBinPath, updateMaxConcurrent, cancelAllExecutions, getActiveExecutions } from '../agents/executor.js';
|
||||
import { invalidateAgentMapCache } from '../agents/pipeline.js';
|
||||
import { cached } from '../cache/index.js';
|
||||
import { readdirSync, readFileSync, unlinkSync, existsSync, mkdirSync, statSync, createReadStream } from 'fs';
|
||||
import { readdirSync, readFileSync, unlinkSync, existsSync, mkdirSync, statSync, createReadStream, rmSync } from 'fs';
|
||||
import { join, dirname, resolve as pathResolve, extname, basename, relative } from 'path';
|
||||
import { createGzip } from 'zlib';
|
||||
import { Readable } from 'stream';
|
||||
@@ -1140,4 +1140,24 @@ router.get('/files/download-folder', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.delete('/files', (req, res) => {
|
||||
try {
|
||||
const targetPath = resolveProjectPath(req.query.path || '');
|
||||
if (!targetPath) return res.status(400).json({ error: 'Caminho inválido' });
|
||||
if (targetPath === PROJECTS_DIR) return res.status(400).json({ error: 'Não é permitido excluir o diretório raiz' });
|
||||
if (!existsSync(targetPath)) return res.status(404).json({ error: 'Arquivo ou pasta não encontrado' });
|
||||
|
||||
const stat = statSync(targetPath);
|
||||
if (stat.isDirectory()) {
|
||||
rmSync(targetPath, { recursive: true, force: true });
|
||||
} else {
|
||||
unlinkSync(targetPath);
|
||||
}
|
||||
|
||||
res.json({ success: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user