From d5858d78364dea7df61cc33d409eb13091783a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 16 Jun 2026 14:57:19 +0400 Subject: [PATCH] =?UTF-8?q?ZIP:=20=D0=BF=D0=BE=D0=BB=D0=BD=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=83=D1=82=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=20(=D0=BF=D0=BE=D0=B4=D0=BF=D0=B0=D0=BF=D0=BA=D0=B8),=20v1.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/app.py | 11 +++++------ site/templates/upload.html | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/site/app.py b/site/app.py index d0bd1ce..8c29b20 100644 --- a/site/app.py +++ b/site/app.py @@ -177,16 +177,15 @@ class ContractsApp: zip_names.append(zname) zdata = zf.read(zname) zmime = mimeutil.guess_mime(zname) or "application/octet-stream" - zbasename = zname.split("/")[-1] if "/" in zname else zname # Сохранить как отдельный документ db.execute( "INSERT INTO documents (filename, mime_type, original_bytes, status) VALUES (%s,%s,%s,'uploaded')", - (zbasename, zmime, zdata), + (zname, zmime, zdata), ) zdoc, _ = db.query_one( "SELECT id FROM documents WHERE filename=%s ORDER BY created_at DESC LIMIT 1", - (zbasename,), + (zname,), ) zdoc_id = zdoc["id"] if zdoc else None if zdoc_id: @@ -198,7 +197,7 @@ class ContractsApp: # Парсинг внутреннего файла zf_start = time_mod.time() total_bytes += len(zdata) - yield f"data: {json.dumps({'type': 'file_start', 'name': zbasename, 'bytes': len(zdata)})}\n\n" + yield f"data: {json.dumps({'type': 'file_start', 'name': zname, 'bytes': len(zdata)})}\n\n" try: zpr = parser_mod.parse(zdata, zmime) @@ -210,9 +209,9 @@ class ContractsApp: ) zelapsed = round(time_mod.time() - zf_start, 1) files_processed += 1 - yield f"data: {json.dumps({'type': 'file_done', 'name': zbasename, 'time_s': zelapsed, 'elements': len(zelements)})}\n\n" + yield f"data: {json.dumps({'type': 'file_done', 'name': zname, 'time_s': zelapsed, 'elements': len(zelements)})}\n\n" except Exception as e: - yield f"data: {json.dumps({'type': 'file_error', 'name': zbasename, 'error': str(e)})}\n\n" + yield f"data: {json.dumps({'type': 'file_error', 'name': zname, 'error': str(e)})}\n\n" except Exception as e: yield f"data: {json.dumps({'type': 'file_error', 'name': s['filename'], 'error': 'ZIP: ' + str(e)})}\n\n" diff --git a/site/templates/upload.html b/site/templates/upload.html index 32d1134..49e809f 100644 --- a/site/templates/upload.html +++ b/site/templates/upload.html @@ -47,7 +47,7 @@
Nubes - Сверка договоров v1.3 + Сверка договоров v1.4
@@ -150,9 +150,8 @@ var zip = await JSZip.loadAsync(f); zip.forEach(function(relativePath, zipEntry) { if (!zipEntry.dir) { - var fname = relativePath.split('/').pop() || relativePath; fileQueue.push({ - name: fname, + name: relativePath, lastModified: zipEntry.date ? zipEntry.date.getTime() : 0, size: 0, isZipChild: true,