Skip to content

Commit

Permalink
fix DomainRecordDuplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
honwen committed Apr 26, 2019
1 parent 1658622 commit 8a312eb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ func (ak *AccessKey) DelRecord(fulldomain string) (err error) {
for i := range dnsRecords {
if dnsRecords[i].RR == rr {
target = &dnsRecords[i]
break
_, err = ak.getClient().DeleteDomainRecord(
&dns.DeleteDomainRecordArgs{
RecordId: target.RecordId,
},
)
}
}
} else {
return err
}
_, err = ak.getClient().DeleteDomainRecord(
&dns.DeleteDomainRecordArgs{
RecordId: target.RecordId,
},
)
return
}

Expand Down Expand Up @@ -120,6 +119,10 @@ func (ak *AccessKey) CheckAndUpdateRecordA(fulldomain, ipaddr string) (err error
} else if target.Value != ipaddr {
err = ak.UpdateRecord(target.RecordId, target.RR, ipaddr)
}
if err != nil && strings.Contains(err.Error(), `DomainRecordDuplicate`) {
ak.DelRecord(fulldomain)
return ak.CheckAndUpdateRecordA(fulldomain, ipaddr)
}
return err
}

Expand Down

0 comments on commit 8a312eb

Please sign in to comment.