Skip to content

Commit

Permalink
add legacy retry and delete file
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Russell committed Feb 2, 2019
1 parent c029b20 commit cec4aec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion legacy/legacy-dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import (
"fmt"
"log"
"net"
"os"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -235,10 +236,12 @@ func LoadGeoliteDataset(filename string, bucketname string) (*GeoIP, error) {
if err != nil {
return nil, err
}
// TODO - looks like this sometimes fails. Perhaps should retry.
defer os.Remove(dataFileName)

gi, err := Open(dataFileName, filename)
if err != nil {
log.Println("Could not open GeoIP database. Retrying.")
// TODO - looks like this retry ALWAYS fails. Look into why.
gi, err = Open(dataFileName, filename)
if err != nil {
return nil, errors.New("could not open GeoIP database")
Expand Down
2 changes: 2 additions & 0 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func FindFile(fn string, zrdr *zip.Reader) (io.ReadCloser, error) {
}

// UncompressGzFile reads a .gz file from GCS and write it to a local file.
// Consumer should delete the file when finished.
func UncompressGzFile(ctx context.Context, bucketName string, fileName string, outputFile string) error {
ctx = context.Background()
client, err := storage.NewClient(ctx)
Expand All @@ -90,6 +91,7 @@ func UncompressGzFile(ctx context.Context, bucketName string, fileName string, o
log.Println(err)
return err
}
// TODO - this could be done incrementally, to use less memory.
data, err := ioutil.ReadAll(gzr)
if err != nil {
return err
Expand Down

0 comments on commit cec4aec

Please sign in to comment.