You've already forked DataMate
fix(annotation): fix file version check to compare with latest version by logical path
Problem: check_file_version was comparing annotation version with the passed file_id's version, but when files are updated, new file records are created with higher versions and old ones are marked ARCHIVED. Solution: 1. Query the latest ACTIVE file by logical_path 2. Compare annotation version with latest file version 3. Return latestFileId so frontend can switch to new version Changes: - check_file_version now queries latest version by logical_path - Added latest_file_id to FileVersionCheckResponse schema - Updated descriptions to clarify currentFileVersion is latest version Database scenario: - old file: id=6dae9f2f, version=1, status=ARCHIVED - new file: id=3365b4e7, version=3, status=ACTIVE - Both have same logical_path='rufus.ini' - Now correctly detects version 3 > annotation version
This commit is contained in:
@@ -198,9 +198,9 @@ class UpsertAnnotationResponse(BaseModel):
|
||||
class FileVersionCheckResponse(BaseModel):
|
||||
"""文件版本检查响应"""
|
||||
|
||||
file_id: str = Field(..., alias="fileId", description="文件ID")
|
||||
file_id: str = Field(..., alias="fileId", description="文件ID(标注关联的文件)")
|
||||
current_file_version: int = Field(
|
||||
..., alias="currentFileVersion", description="当前文件版本"
|
||||
..., alias="currentFileVersion", description="当前最新文件版本"
|
||||
)
|
||||
annotation_file_version: Optional[int] = Field(
|
||||
None, alias="annotationFileVersion", description="标注时的文件版本"
|
||||
@@ -213,6 +213,9 @@ class FileVersionCheckResponse(BaseModel):
|
||||
has_new_version: bool = Field(
|
||||
..., alias="hasNewVersion", description="是否有新版本"
|
||||
)
|
||||
latest_file_id: Optional[str] = Field(
|
||||
None, alias="latestFileId", description="最新版本文件的ID(如有新版本)"
|
||||
)
|
||||
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user