From 8dee6f70b3a39fa7157f84c0d21e7730aae84ae7 Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Tue, 24 Feb 2026 22:22:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EC=97=90=20fileHash=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 게임 EXE의 SHA256 해시를 저장하여 런처가 버전 검증에 활용 Co-Authored-By: Claude Sonnet 4.6 --- internal/download/handler.go | 7 ++++--- internal/download/model.go | 1 + internal/download/service.go | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/download/handler.go b/internal/download/handler.go index 0ebb15a..f6bc46d 100644 --- a/internal/download/handler.go +++ b/internal/download/handler.go @@ -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": "업데이트에 실패했습니다"}) } diff --git a/internal/download/model.go b/internal/download/model.go index 5a78800..8a26cd6 100644 --- a/internal/download/model.go +++ b/internal/download/model.go @@ -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:''"` } diff --git a/internal/download/service.go b/internal/download/service.go index 413f682..42ef60d 100644 --- a/internal/download/service.go +++ b/internal/download/service.go @@ -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) }