[#114] nns: Move deleting global aliases along with TXT records
All checks were successful
DCO action / DCO (pull_request) Successful in 27s
Code generation / Generate wrappers (pull_request) Successful in 1m18s
Tests / Tests (pull_request) Successful in 1m20s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2024-09-23 13:25:42 +03:00
parent 9632ef8970
commit 820bd283c1

View file

@ -509,12 +509,16 @@ func deleteRecords(ctx storage.Context, name string, typ RecordType) {
tokenID := []byte(tokenIDFromName(name))
ns := getNameState(ctx, tokenID)
ns.checkAdmin()
globalDomainStorage := append([]byte{prefixGlobalDomain}, getTokenKey([]byte(name))...)
globalDomainRaw := storage.Get(ctx, globalDomainStorage)
globalDomain := globalDomainRaw.(string)
if globalDomainRaw != nil && globalDomain != "" {
deleteDomain(ctx, globalDomain)
if typ == TXT {
globalDomainKey := append([]byte{prefixGlobalDomain}, getTokenKey([]byte(name))...)
globalDomainRaw := storage.Get(ctx, globalDomainKey)
if globalDomainRaw != nil {
globalDomain := globalDomainRaw.(string)
if globalDomain != "" {
deleteDomain(ctx, globalDomain)
}
storage.Delete(ctx, globalDomainKey)
}
}
recordsKey := getRecordsKeyByType(tokenID, name, typ)
@ -550,13 +554,6 @@ func deleteDomain(ctx storage.Context, name string) {
ns := std.Deserialize(nsRaw.([]byte)).(NameState)
ns.checkAdmin()
globalNSKey := append([]byte{prefixGlobalDomain}, getTokenKey([]byte(name))...)
globalDomainRaw := storage.Get(ctx, globalNSKey)
globalDomain := globalDomainRaw.(string)
if globalDomainRaw != nil && globalDomain != "" {
deleteDomain(ctx, globalDomain)
}
deleteRecords(ctx, name, CNAME)
deleteRecords(ctx, name, TXT)
deleteRecords(ctx, name, A)