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()