Skip to content

Commit 4b951d4

Browse files
committed
fix: 동일 파일이 존재할 시 에러가 아닌 기존 파일을 반환
1 parent 5279c20 commit 4b951d4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • app/participant_portal_api/serializers

app/participant_portal_api/serializers/file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def create(self, validated_data: dict) -> PublicFile:
1818
new_file = PublicFile(file=validated_data["file"])
1919
new_file.clean()
2020

21-
if new_file.hash and PublicFile.objects.filter(hash=new_file.hash).exists():
22-
raise serializers.ValidationError({"file": "A file with the same hash already exists."})
21+
if new_file.hash and (pf := PublicFile.objects.filter(hash=new_file.hash).exists()):
22+
return pf
2323

2424
new_file.save()
2525
return new_file

0 commit comments

Comments
 (0)