diff --git a/dental-server/installer/check-installation.js b/dental-server/installer/check-installation.js index 843ea90..598b76e 100644 --- a/dental-server/installer/check-installation.js +++ b/dental-server/installer/check-installation.js @@ -3,7 +3,7 @@ const path = require('path'); const db = require('../database'); async function checkInstallation() { - const installedFile = fs.existsSync(path.join(__dirname, '..', '.installed')); + const installedFile = fs.existsSync(path.join(__dirname, '..', 'data', '.installed')); let currentVersion = '1.0.0'; let databaseExists = false; let userExists = false; diff --git a/dental-server/server.js b/dental-server/server.js index c15c990..ef1eace 100644 --- a/dental-server/server.js +++ b/dental-server/server.js @@ -349,7 +349,7 @@ app.post('/api/install', async (req, res) => { console.log('✅ Usuário admin criado:', admin.username); // Criar arquivo .installed - const installedPath = path.join(__dirname, '.installed'); + const installedPath = path.join(__dirname, 'data', '.installed'); await fs.writeFile(installedPath, new Date().toISOString()); // Criar arquivo version.txt @@ -505,7 +505,8 @@ async function checkInstallationMiddleware(req, res, next) { // Para APIs que não são de instalação ou auth, verificar instalação if (isApiRoute) { try { - const installedFile = path.join(__dirname, '.installed'); + // Procura no diretório persistente de dados + const installedFile = path.join(__dirname, 'data', '.installed'); const fsSync = require('fs'); if (!fsSync.existsSync(installedFile)) { @@ -522,7 +523,7 @@ async function checkInstallationMiddleware(req, res, next) { // Se não for API e não for rota pública liberada acima, e estiver sem .installed, // manda pro install. try { - const installedFile = path.join(__dirname, '.installed'); + const installedFile = path.join(__dirname, 'data', '.installed'); const fsSync = require('fs'); if (!fsSync.existsSync(installedFile)) { return res.redirect('/install'); @@ -1003,7 +1004,7 @@ async function start() { console.log(`🖼️ Processed at: ${PROCESSED_DIR}`); console.log('═══════════════════════════════════════════════════════'); - const installedFile = path.join(__dirname, '.installed'); + const installedFile = path.join(__dirname, 'data', '.installed'); if (!fsSync.existsSync(installedFile)) { console.log('⚠️ Sistema não instalado. Acesse /install para configurar.'); }