Skip to content

Commit 1f2da0a

Browse files
committed
read old index.pidx to obtain URL before using the default
1 parent 955896d commit 1f2da0a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cmd/installer/root.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,17 +791,25 @@ func GetIndexPath(indexPath string) (string, error) {
791791
func UpdatePublicIndexIfOnline() error {
792792
// If public index already exists then first check if online, then its timestamp
793793
// if we are online and it is too old then download a current version
794+
publicIndex := DefaultPublicIndex
794795
if utils.FileExists(Installation.PublicIndex) {
795796
err := utils.CheckConnection(ConnectionTryURL, 0)
796797
if err != nil && errors.Unwrap(err) != errs.ErrOffline {
797798
return err
798799
}
799800
if errors.Unwrap(err) != errs.ErrOffline {
801+
pidxXML := xml.NewPidxXML(Installation.PublicIndex)
802+
if err := pidxXML.Read(); err != nil { // new public index XML
803+
pidxXML.URL = "" // set URL to empty to avoid using it
804+
}
800805
var updateConf updateCfg
801806
err = Installation.checkUpdateCfg(&updateConf)
802807
if err != nil {
808+
if pidxXML.URL != "" {
809+
publicIndex = pidxXML.URL + PublicIndexName
810+
}
803811
UnlockPackRoot()
804-
err1 := UpdatePublicIndex(DefaultPublicIndex, true, false, false, false, 0, 0)
812+
err1 := UpdatePublicIndex(publicIndex, true, false, false, false, 0, 0)
805813
if err1 != nil {
806814
return err1
807815
}
@@ -814,7 +822,7 @@ func UpdatePublicIndexIfOnline() error {
814822
// if public index does not or not yet exist then download without check
815823
if !utils.FileExists(Installation.PublicIndex) {
816824
UnlockPackRoot()
817-
err1 := UpdatePublicIndex(DefaultPublicIndex, true, false, false, false, 0, 0)
825+
err1 := UpdatePublicIndex(publicIndex, true, false, false, false, 0, 0)
818826
if err1 != nil {
819827
return err1
820828
}

0 commit comments

Comments
 (0)