From e1d0e6fed02a2c630518b00f88c61f85b52c4b20 Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Mon, 13 Apr 2026 02:56:10 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20downloadBody=20=EB=AC=B8=EC=84=9C?= =?UTF-8?q?=ED=99=94=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- download.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/download.go b/download.go index ec9a2e9..2d74381 100644 --- a/download.go +++ b/download.go @@ -128,6 +128,7 @@ func formatProgress(pct int, speedBytesPerSec float64, remaining float64) string // downloadBody 응답 본문을 tmpFile에 쓰고 진행률을 갱신한다. // downloaded는 이어받기 시작 오프셋, total은 전체 크기(미확정이면 0). +// tmpPath는 크기 초과 시 파일 삭제에만 사용된다. // 완료 또는 오류 시 tmpFile을 닫는다. func downloadBody(resp *http.Response, tmpFile *os.File, tmpPath string, downloaded, total int64) error { buf := make([]byte, 32*1024) @@ -154,6 +155,7 @@ func downloadBody(resp *http.Response, tmpFile *os.File, tmpPath string, downloa return fmt.Errorf("다운로드 크기가 제한을 초과했습니다") } + // 500ms마다 속도 계산 및 진행률 갱신 now := time.Now() if now.Sub(lastSpeedUpdate) >= 500*time.Millisecond { elapsed := now.Sub(lastSpeedUpdate).Seconds()