fix: add fallback to not gzziped version
This commit is contained in:
parent
8763e0013d
commit
e9473847ca
|
@ -92,7 +92,10 @@ func (dl *ServerDataLoader) LoadOD(tribe bool) (map[int]*twmodel.OpponentsDefeat
|
|||
}
|
||||
lines, err := dl.getCSVData(formattedURL, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, formattedURL %s", formattedURL)
|
||||
lines, err = dl.getCSVData(strings.ReplaceAll(formattedURL, ".gz", ""), false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, formattedURL %s", formattedURL)
|
||||
}
|
||||
}
|
||||
for _, line := range lines {
|
||||
parsed, err := dl.parseODLine(line)
|
||||
|
@ -163,7 +166,10 @@ func (dl *ServerDataLoader) LoadPlayers() ([]*twmodel.Player, error) {
|
|||
formattedURL := buildURL(dl.baseURL, EndpointPlayer)
|
||||
lines, err := dl.getCSVData(formattedURL, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, url %s", formattedURL)
|
||||
lines, err = dl.getCSVData(strings.ReplaceAll(formattedURL, ".gz", ""), false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, formattedURL %s", formattedURL)
|
||||
}
|
||||
}
|
||||
|
||||
var players []*twmodel.Player
|
||||
|
@ -228,7 +234,10 @@ func (dl *ServerDataLoader) LoadTribes() ([]*twmodel.Tribe, error) {
|
|||
formattedURL := buildURL(dl.baseURL, EndpointTribe)
|
||||
lines, err := dl.getCSVData(formattedURL, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, url %s", formattedURL)
|
||||
lines, err = dl.getCSVData(dl.baseURL+EndpointTribeNotGzipped, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, url %s", formattedURL)
|
||||
}
|
||||
}
|
||||
var tribes []*twmodel.Tribe
|
||||
for _, line := range lines {
|
||||
|
@ -282,7 +291,10 @@ func (dl *ServerDataLoader) LoadVillages() ([]*twmodel.Village, error) {
|
|||
formattedURL := buildURL(dl.baseURL, EndpointVillage)
|
||||
lines, err := dl.getCSVData(formattedURL, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, formattedURL %s", formattedURL)
|
||||
lines, err = dl.getCSVData(dl.baseURL+EndpointVillageNotGzipped, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, formattedURL %s", formattedURL)
|
||||
}
|
||||
}
|
||||
var villages []*twmodel.Village
|
||||
for _, line := range lines {
|
||||
|
@ -338,6 +350,9 @@ func (dl *ServerDataLoader) LoadEnnoblements(cfg *LoadEnnoblementsConfig) ([]*tw
|
|||
compressed = false
|
||||
}
|
||||
lines, err := dl.getCSVData(formattedURL, compressed)
|
||||
if err != nil && compressed {
|
||||
lines, err = dl.getCSVData(dl.baseURL+EndpointConquerNotGzipped, false)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't load data, formattedURL %s", formattedURL)
|
||||
}
|
||||
|
|
Reference in New Issue