fix: file upload error

This commit is contained in:
tao.chen
2026-08-14 18:22:46 +08:00
parent c65d6dc684
commit 5d49ff5e34
14 changed files with 872 additions and 604 deletions
+18 -11
View File
@@ -1,7 +1,7 @@
import datetime
from typing import Optional
from sqlalchemy import BINARY, Index, JSON, String, text
from sqlalchemy import BINARY, Computed, Index, JSON, String, text
from sqlalchemy.dialects.mysql import BIGINT, CHAR, DATETIME, TINYINT
from sqlalchemy.orm import Mapped, mapped_column
@@ -22,6 +22,12 @@ class StorageObjects(Base):
Index("idx_storage_content_hash", "content_hash"),
Index("idx_storage_owner", "owner_user_id", "object_status"),
Index("idx_storage_parent", "parent_object_id"),
Index(
"idx_storage_workspace_path",
"workspace_id",
"storage_backend",
"path_hash",
),
Index(
"idx_storage_workspace_usage",
"workspace_id",
@@ -29,17 +35,10 @@ class StorageObjects(Base):
"object_status",
),
Index(
"uk_storage_bucket_key",
"uk_storage_bucket_key_active",
"storage_backend",
"bucket_name",
"object_key_hash",
unique=True,
),
Index(
"uk_storage_workspace_path",
"workspace_id",
"storage_backend",
"path_hash",
"object_key_hash_active",
unique=True,
),
{"comment": "Workspace 文件和 RustFS 对象的统一元数据"},
@@ -56,7 +55,7 @@ class StorageObjects(Base):
comment="working_copy/public_script/data_resource/version_artifact/snapshot/run_log/run_result",
)
storage_backend: Mapped[str] = mapped_column(
String(16), nullable=False, comment="rustfs"
String(16), nullable=False, comment="s3"
)
storage_uri: Mapped[str] = mapped_column(String(1500), nullable=False)
file_name: Mapped[str] = mapped_column(String(255), nullable=False)
@@ -100,6 +99,14 @@ class StorageObjects(Base):
object_key_hash: Mapped[Optional[bytes]] = mapped_column(
BINARY(32), comment="SHA-256(object_key),由应用写入"
)
object_key_hash_active: Mapped[Optional[bytes]] = mapped_column(
BINARY(32),
Computed(
"CASE WHEN object_status = 'available' THEN object_key_hash ELSE NULL END",
persisted=False,
),
comment="VIRTUAL generated column used by uk_storage_bucket_key_active",
)
file_extension: Mapped[Optional[str]] = mapped_column(String(32))
mime_type: Mapped[Optional[str]] = mapped_column(String(255))
content_hash: Mapped[Optional[str]] = mapped_column(