mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-15 22:27:34 +08:00
Remove unimplemented client-provided ID from upload API
The `id` field on UploadAssetSpec was advertised for idempotent creation but never actually honored when creating new references. Remove it rather than implementing the feature. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a832837af8
commit
d5601fc9a9
@ -405,29 +405,6 @@ async def upload_asset(request: web.Request) -> web.Response:
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Idempotent create: if spec.id is provided, check if reference already exists
|
|
||||||
if spec.id:
|
|
||||||
existing = get_asset_detail(
|
|
||||||
reference_id=spec.id,
|
|
||||||
owner_id=owner_id,
|
|
||||||
)
|
|
||||||
if existing:
|
|
||||||
# Validate that uploaded content matches existing asset
|
|
||||||
if spec.hash and existing.asset and existing.asset.hash != spec.hash:
|
|
||||||
delete_temp_file_if_exists(parsed.tmp_path)
|
|
||||||
return _build_error_response(
|
|
||||||
409,
|
|
||||||
"HASH_MISMATCH",
|
|
||||||
"Uploaded file hash does not match existing asset.",
|
|
||||||
)
|
|
||||||
delete_temp_file_if_exists(parsed.tmp_path)
|
|
||||||
asset = _build_asset_response(existing)
|
|
||||||
payload_out = schemas_out.AssetCreated(
|
|
||||||
**asset.model_dump(),
|
|
||||||
created_new=False,
|
|
||||||
)
|
|
||||||
return web.json_response(payload_out.model_dump(mode="json", exclude_none=True), status=200)
|
|
||||||
|
|
||||||
# Fast path: hash exists, create AssetReference without writing anything
|
# Fast path: hash exists, create AssetReference without writing anything
|
||||||
if spec.hash and parsed.provided_hash_exists is True:
|
if spec.hash and parsed.provided_hash_exists is True:
|
||||||
result = create_from_hash(
|
result = create_from_hash(
|
||||||
@ -464,7 +441,6 @@ async def upload_asset(request: web.Request) -> web.Response:
|
|||||||
expected_hash=spec.hash,
|
expected_hash=spec.hash,
|
||||||
mime_type=spec.mime_type,
|
mime_type=spec.mime_type,
|
||||||
preview_id=spec.preview_id,
|
preview_id=spec.preview_id,
|
||||||
asset_id=spec.id,
|
|
||||||
)
|
)
|
||||||
except AssetValidationError as e:
|
except AssetValidationError as e:
|
||||||
delete_temp_file_if_exists(parsed.tmp_path)
|
delete_temp_file_if_exists(parsed.tmp_path)
|
||||||
|
|||||||
@ -241,7 +241,6 @@ class UploadAssetSpec(BaseModel):
|
|||||||
- name: display name
|
- name: display name
|
||||||
- user_metadata: arbitrary JSON object (optional)
|
- user_metadata: arbitrary JSON object (optional)
|
||||||
- hash: optional canonical 'blake3:<hex>' for validation / fast-path
|
- hash: optional canonical 'blake3:<hex>' for validation / fast-path
|
||||||
- id: optional UUID for idempotent creation
|
|
||||||
- mime_type: optional MIME type override
|
- mime_type: optional MIME type override
|
||||||
- preview_id: optional asset ID for preview
|
- preview_id: optional asset ID for preview
|
||||||
|
|
||||||
@ -254,7 +253,6 @@ class UploadAssetSpec(BaseModel):
|
|||||||
name: str | None = Field(default=None, max_length=512, description="Display Name")
|
name: str | None = Field(default=None, max_length=512, description="Display Name")
|
||||||
user_metadata: dict[str, Any] = Field(default_factory=dict)
|
user_metadata: dict[str, Any] = Field(default_factory=dict)
|
||||||
hash: str | None = Field(default=None)
|
hash: str | None = Field(default=None)
|
||||||
id: str | None = Field(default=None)
|
|
||||||
mime_type: str | None = Field(default=None)
|
mime_type: str | None = Field(default=None)
|
||||||
preview_id: str | None = Field(default=None)
|
preview_id: str | None = Field(default=None)
|
||||||
|
|
||||||
|
|||||||
@ -258,7 +258,6 @@ def upload_from_temp_path(
|
|||||||
expected_hash: str | None = None,
|
expected_hash: str | None = None,
|
||||||
mime_type: str | None = None,
|
mime_type: str | None = None,
|
||||||
preview_id: str | None = None,
|
preview_id: str | None = None,
|
||||||
asset_id: str | None = None,
|
|
||||||
) -> UploadResult:
|
) -> UploadResult:
|
||||||
try:
|
try:
|
||||||
digest, _ = hashing.compute_blake3_hash(temp_path)
|
digest, _ = hashing.compute_blake3_hash(temp_path)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user