Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 25a84a4

Browse files
authored
Merge pull request #2058 from OpenBazaar/bulk
Fix bug bulk updating currencies on listings
2 parents 52861e8 + d1754ec commit 25a84a4

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

core/listings.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error {
657657
if err != nil {
658658
return err
659659
}
660-
661660
walkpath := func(p string, f os.FileInfo, err error) error {
662661
if !f.IsDir() && filepath.Ext(p) == ".json" {
663662
signedProto, err := GetSignedListingFromPath(p)
@@ -674,7 +673,6 @@ func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error {
674673
if l.GetContractType() == pb.Listing_Metadata_CRYPTOCURRENCY.String() {
675674
return nil
676675
}
677-
678676
if err := l.SetAcceptedCurrencies(currencies...); err != nil {
679677
return err
680678
}
@@ -701,6 +699,5 @@ func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error {
701699
if err != nil {
702700
return err
703701
}
704-
705702
return nil
706703
}

openbazaar-qa renamed to qa/ob

73.5 MB
Binary file not shown.

repo/listing.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,10 +1029,21 @@ func (l *Listing) GetShippingOptions() ([]*pb.Listing_ShippingOption, error) {
10291029
}
10301030
switch l.GetVersion() {
10311031
case 3, 4:
1032-
for _, o := range so {
1033-
for _, s := range o.Services {
1034-
s.BigPrice = big.NewInt(int64(s.Price)).String()
1035-
s.BigAdditionalItemPrice = big.NewInt(int64(s.AdditionalItemPrice)).String()
1032+
for a, o := range so {
1033+
for x, s := range o.Services {
1034+
so[a].Services[x].BigPrice = big.NewInt(int64(s.Price)).String()
1035+
so[a].Services[x].BigAdditionalItemPrice = big.NewInt(int64(s.AdditionalItemPrice)).String()
1036+
}
1037+
}
1038+
case 5:
1039+
for a, o := range so {
1040+
for x, s := range o.Services {
1041+
if s.BigPrice == "" {
1042+
so[a].Services[x].BigPrice = "0"
1043+
}
1044+
if s.BigAdditionalItemPrice == "" {
1045+
so[a].Services[x].BigAdditionalItemPrice = "0"
1046+
}
10361047
}
10371048
}
10381049
}
@@ -1212,6 +1223,9 @@ func (l *Listing) GetInventory() (map[int]*big.Int, error) {
12121223
var amtStr string
12131224
switch l.GetVersion() {
12141225
case 5:
1226+
if s.BigQuantity == "" {
1227+
continue
1228+
}
12151229
amtStr = s.BigQuantity
12161230
default:
12171231
amtStr = strconv.Itoa(int(s.Quantity))

0 commit comments

Comments
 (0)