From 9eec45cbd0158a7e55b0956bd90b9ba33df46383 Mon Sep 17 00:00:00 2001 From: wren <“porlong@qq.com”> Date: Wed, 13 May 2026 16:32:42 +0800 Subject: [PATCH] fix: remove sha256 duplicate check so re-upload always creates new version in group --- .../services/impl/documentServiceImpl.py | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/fastapi_modules/fastapi_leaudit/services/impl/documentServiceImpl.py b/fastapi_modules/fastapi_leaudit/services/impl/documentServiceImpl.py index c0947c3..bca5b1d 100644 --- a/fastapi_modules/fastapi_leaudit/services/impl/documentServiceImpl.py +++ b/fastapi_modules/fastapi_leaudit/services/impl/documentServiceImpl.py @@ -161,25 +161,17 @@ class DocumentServiceImpl(IDocumentService): normalized_name=normalizedName, ) - if latestCandidate and latestCandidate["sha256"] == fileSha256: - duplicateUpload = True - document = await Session.get(LeauditDocument, int(latestCandidate["document_id"])) - documentFile = await Session.get(LeauditDocumentFile, int(latestCandidate["file_id"])) - if document is None or documentFile is None: - raise LeauditException(StatusCodeEnum.HTTP_500_INTERNAL_SERVER_ERROR, "重复上传版本定位失败") - await Session.commit() + internalDocumentNo = time.time_ns() + if latestCandidate: + previousVersionId = int(latestCandidate["document_id"]) + rootVersionId = int(latestCandidate["root_version_id"] or latestCandidate["document_id"]) + versionGroupKey = str(latestCandidate["version_group_key"]) + versionNo = int(latestCandidate["version_no"]) + 1 + previousDocument = await Session.get(LeauditDocument, previousVersionId) + if previousDocument is not None: + previousDocument.isLatestVersion = False else: - internalDocumentNo = time.time_ns() - if latestCandidate: - previousVersionId = int(latestCandidate["document_id"]) - rootVersionId = int(latestCandidate["root_version_id"] or latestCandidate["document_id"]) - versionGroupKey = str(latestCandidate["version_group_key"]) - versionNo = int(latestCandidate["version_no"]) + 1 - previousDocument = await Session.get(LeauditDocument, previousVersionId) - if previousDocument is not None: - previousDocument.isLatestVersion = False - else: - versionGroupKey = uuid.uuid4().hex + versionGroupKey = uuid.uuid4().hex document = await LeauditDocument.create_new( Session,