feat: 다운로드 정보에 fileHash 필드 추가
All checks were successful
Server CI/CD / deploy (push) Successful in 38s

게임 EXE의 SHA256 해시를 저장하여 런처가 버전 검증에 활용

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 22:22:37 +09:00
parent 3fb182c271
commit 8dee6f70b3
3 changed files with 7 additions and 4 deletions

View File

@@ -24,11 +24,12 @@ func (h *Handler) Upsert(c *fiber.Ctx) error {
Version string `json:"version"`
FileName string `json:"fileName"`
FileSize string `json:"fileSize"`
FileHash string `json:"fileHash"`
}
if err := c.BodyParser(&body); err != nil || body.URL == "" || body.Version == "" {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "url version 필수입니다"})
if err := c.BodyParser(&body); err != nil || body.URL == "" || body.Version == "" || body.FileHash == "" {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "url, version, fileHash는 필수입니다"})
}
info, err := h.svc.Upsert(body.URL, body.Version, body.FileName, body.FileSize)
info, err := h.svc.Upsert(body.URL, body.Version, body.FileName, body.FileSize, body.FileHash)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "업데이트에 실패했습니다"})
}

View File

@@ -15,4 +15,5 @@ type Info struct {
Version string `json:"version" gorm:"not null"`
FileName string `json:"fileName" gorm:"not null"`
FileSize string `json:"fileSize" gorm:"not null"`
FileHash string `json:"fileHash" gorm:"not null;default:''"`
}

View File

@@ -12,7 +12,7 @@ func (s *Service) GetInfo() (*Info, error) {
return s.repo.GetLatest()
}
func (s *Service) Upsert(url, version, fileName, fileSize string) (*Info, error) {
func (s *Service) Upsert(url, version, fileName, fileSize, fileHash string) (*Info, error) {
info, err := s.repo.GetLatest()
if err != nil {
info = &Info{}
@@ -21,5 +21,6 @@ func (s *Service) Upsert(url, version, fileName, fileSize string) (*Info, error)
info.Version = version
info.FileName = fileName
info.FileSize = fileSize
info.FileHash = fileHash
return info, s.repo.Save(info)
}