diff --git a/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx b/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx index 93cd78a..fc5a0b1 100644 Binary files a/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx and b/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx differ diff --git a/renderer/carbone-templates/registry.json b/renderer/carbone-templates/registry.json index 2c0a881..1086756 100644 --- a/renderer/carbone-templates/registry.json +++ b/renderer/carbone-templates/registry.json @@ -6,6 +6,6 @@ "originalName": "master_cv_template.docx", "path": "/root/workspace/cv-app/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx", "uploadedAt": "2026-07-16T09:03:29.601Z", - "updatedAt": "2026-07-16T11:17:19.354Z" + "updatedAt": "2026-07-16T11:21:01.888Z" } ] \ No newline at end of file diff --git a/renderer/onlyoffice-service.js b/renderer/onlyoffice-service.js index 1c8ed69..30d6e51 100644 --- a/renderer/onlyoffice-service.js +++ b/renderer/onlyoffice-service.js @@ -146,10 +146,11 @@ router.get('/:templateId/config', (req, res) => { const docKey = generateDocKey(templateId, fileMtime); const fileName = template.originalName || template.name + '.docx'; - // Add cache-busting timestamp to the document URL so ONLYOFFICE - // always fetches the latest version from our backend - const cacheBuster = Date.now(); - const documentUrl = `${BACKEND_PUBLIC_URL}/api/onlyoffice/${templateId}/download?cb=${cacheBuster}`; + // Add file mtime as cache-buster to the document URL so ONLYOFFICE + // always fetches the latest version from our backend. + // The mtime changes every time the file is saved, so the URL is + // different after each save, forcing ONLYOFFICE to re-download. + const documentUrl = `${BACKEND_PUBLIC_URL}/api/onlyoffice/${templateId}/download?mtime=${fileMtime}&cb=${Date.now()}`; const callbackUrl = `${BACKEND_PUBLIC_URL}/api/onlyoffice/${templateId}/callback`; const config = { @@ -316,6 +317,17 @@ router.post('/:templateId/callback', async (req, res) => { console.log(`Template "${template.name}" updated successfully (${response.data.length} bytes)`); + // Clear ONLYOFFICE's internal document cache for this template + // so the next edit session fetches the fresh file + try { + const { execSync } = require('child_process'); + execSync(`docker exec onlyoffice-server find /var/lib/onlyoffice/documentserver/App_Data/cache -name "cvtemplate_${templateId}*" -type d -exec rm -rf {} + 2>/dev/null || true`, { timeout: 5000 }); + console.log('ONLYOFFICE cache cleared for template:', templateId); + } catch (cacheErr) { + // Non-fatal — cache will expire naturally + console.log('Cache clear skipped:', cacheErr.message.substring(0, 100)); + } + // ONLYOFFICE expects a JSON response acknowledging the save return res.json({ error: 0, diff --git a/static/index.html b/static/index.html index 83c8ff3..5e32c0c 100644 --- a/static/index.html +++ b/static/index.html @@ -139,7 +139,7 @@
- - + +