From 1b08bb0e61ecdee15e894845cd09cbc49ca9d2fb Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 10 Sep 2019 11:43:20 +0200 Subject: [PATCH] fix bug with non latin titles for claim names hard exit when a duplicate name is attempted --- manager/manager.go | 1 + manager/ytsync.go | 1 + namer/names.go | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/manager/manager.go b/manager/manager.go index c16bfff..925d733 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -209,6 +209,7 @@ func (s *SyncManager) Start() error { "failure uploading wallet", "the channel in the wallet is different than the channel in the database", "this channel does not belong to this wallet!", + "You already have a stream claim published under the name", } if util.SubstringInSlice(err.Error(), fatalErrors) { return errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err) diff --git a/manager/ytsync.go b/manager/ytsync.go index aacf3b7..bc366ce 100644 --- a/manager/ytsync.go +++ b/manager/ytsync.go @@ -754,6 +754,7 @@ func (s *Sync) startWorker(workerNum int) { "cannot concatenate 'str' and 'NoneType' objects", "more than 90% of the space has been used.", "Couldn't find private key for id", + "You already have a stream claim published under the name", } if util.SubstringInSlice(err.Error(), fatalErrors) || s.Manager.SyncFlags.StopOnError { s.grp.Stop() diff --git a/namer/names.go b/namer/names.go index 531bb67..e951fc7 100644 --- a/namer/names.go +++ b/namer/names.go @@ -43,9 +43,16 @@ func (n *Namer) GetNextName(prefix string) string { } //if for some reasons the title can't be converted in a valid claim name (too short or not latin) then we use a hash + attempt = 1 if len(name) < 2 { sum := md5.Sum([]byte(prefix)) - name = fmt.Sprintf("%s-%d", hex.EncodeToString(sum[:])[:15], attempt) + for { + name = fmt.Sprintf("%s-%d", hex.EncodeToString(sum[:])[:15], attempt) + if _, exists := n.names[name]; !exists { + break + } + attempt++ + } } n.names[name] = true