diff --git a/main.go b/main.go index 692622c..bf822af 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ const ( ) const maxDownloadSize = 2 << 30 // 2GB +const maxExtractFileSize = 4 << 30 // 개별 파일 최대 4GB var checkRedirect = func(req *http.Request, via []*http.Request) error { if req.URL.Scheme != "https" && req.URL.Scheme != "http" { @@ -559,7 +560,7 @@ func extractZip(zipPath, destDir string) error { rc.Close() return err } - _, err = io.Copy(out, rc) + _, err = io.Copy(out, io.LimitReader(rc, maxExtractFileSize)) out.Close() rc.Close() if err != nil { @@ -589,6 +590,7 @@ func moveContents(srcDir, dstDir string) error { if err := os.Rename(src, dst); err != nil { // 드라이브가 다를 경우 복사 후 삭제 if err := copyFile(src, dst); err != nil { + os.Remove(dst) // 실패한 부분 파일 제거 return err } }