fix server crash on row length
parent
70596ed8d5
commit
be2616438f
|
@ -115,7 +115,7 @@ func fetchProducts(srv *sheets.Service) error {
|
|||
|
||||
for _, row := range resp.Values[1:] { // skip first google worksheet row
|
||||
// maybe some error in google sheets table
|
||||
if len(row) < 2 {
|
||||
if len(row) < 3 {
|
||||
logger.AddSystemLog(rslogger.LogTypeError, "Skipped row, because row length less than 2")
|
||||
continue
|
||||
}
|
||||
|
@ -131,13 +131,13 @@ func fetchProducts(srv *sheets.Service) error {
|
|||
|
||||
var productVariant string
|
||||
|
||||
if len(row) >= 3 && row[3] != "" {
|
||||
if len(row) > 3 && row[3] != "" {
|
||||
productVariant = fmt.Sprintf("%v", row[3])
|
||||
}
|
||||
|
||||
var productCharacteristics string
|
||||
|
||||
if len(row) >= 4 && row[4] != "" {
|
||||
if len(row) > 4 && row[4] != "" {
|
||||
productCharacteristics = fmt.Sprintf("%v", row[4])
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,8 @@ func fetchProducts(srv *sheets.Service) error {
|
|||
})
|
||||
}
|
||||
|
||||
logger.AddSystemLog(rslogger.LogTypeWarning, "row %v len %v", row, len(row))
|
||||
|
||||
// cache product
|
||||
|
||||
if state == 1 {
|
||||
|
@ -172,7 +174,7 @@ func fetchProducts(srv *sheets.Service) error {
|
|||
} else if state == 3 {
|
||||
var url string
|
||||
|
||||
if len(row) >= 8 && row[8] != "" {
|
||||
if len(row) > 8 && row[8] != "" {
|
||||
url = fmt.Sprintf("%v", row[8])
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue