Skip to content

Commit

Permalink
Fixed mongod not found error on latest mongo versions
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Sanino <[email protected]>
  • Loading branch information
saniales committed Nov 27, 2022
1 parent 495329b commit 823b5ff
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions mongobin/getOrDownload.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ func GetOrDownloadMongod(urlStr string, cachePath string, logger *memongolog.Log

tarReader := tar.NewReader(gzReader)

const maxFilesCount = 2
fileCount := 0
for {
nextFile, tarErr := tarReader.Next()
if tarErr == io.EOF {
Expand All @@ -101,15 +99,13 @@ func GetOrDownloadMongod(urlStr string, cachePath string, logger *memongolog.Log
return "", fmt.Errorf("error reading from tar: %s", tarErr)
}

if strings.HasSuffix(nextFile.Name, "bin/mongod") || strings.HasSuffix(nextFile.Name, "bin/mongo") {
fileCount++
if strings.HasSuffix(nextFile.Name, "bin/mongod") {
err := saveFile(path.Join(dirPath, filepath.Base(nextFile.Name)), tarReader, logger)
if err != nil {
return "", err
}
if fileCount >= maxFilesCount {
break
}

break
}
}

Expand Down

0 comments on commit 823b5ff

Please sign in to comment.