File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ import (
1212
1313// ExtractTarGz extracts a tar.gz archive to the specified destination directory.
1414func ExtractTarGz (reader io.Reader , destDir string ) error {
15+ if _ , err := os .Stat (destDir ); os .IsNotExist (err ) {
16+ return fmt .Errorf ("destination directory does not exist: %s" , destDir )
17+ }
18+
1519 gzReader , err := gzip .NewReader (reader )
1620 if err != nil {
1721 return fmt .Errorf ("failed to create gzip reader: %w" , err )
Original file line number Diff line number Diff line change 66 "fmt"
77
88 "net/http"
9- "os"
109 "sheriff/internal/compress"
1110 "sheriff/internal/repository"
1211 "strings"
@@ -116,11 +115,6 @@ func (s githubService) DownloadRepository(project repository.Project, dir string
116115 return fmt .Errorf ("failed to download GitHub archive, status: %s" , resp .Status )
117116 }
118117
119- // Create directory if it doesn't exist
120- if err := os .MkdirAll (dir , 0755 ); err != nil {
121- return fmt .Errorf ("failed to create directory: %w" , err )
122- }
123-
124118 return compress .ExtractTarGz (resp .Body , dir )
125119}
126120
You can’t perform that action at this time.
0 commit comments