From ce3928f7e64d4b09d05f0bd1810266e30a1d710f Mon Sep 17 00:00:00 2001
From: RandomChars <random@chars.jp>
Date: Tue, 28 Sep 2021 12:36:54 +0900
Subject: [PATCH] check for existing tag when tagging

---
 store/image.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/store/image.go b/store/image.go
index 42f5289..c4d3c40 100644
--- a/store/image.go
+++ b/store/image.go
@@ -439,7 +439,8 @@ func (s *Store) ImageDestroy(hash string) {
 
 // ImageTagAdd adds a tag to an image with specific snowflake.
 func (s *Store) ImageTagAdd(flake, tag string) {
-	if !nameRegex.MatchString(tag) || !s.flake(flake) || !s.dir(s.ImageTagsPath(flake)) || !s.dir(s.TagPath(tag)) {
+	if !nameRegex.MatchString(tag) || !s.flake(flake) || !s.dir(s.ImageTagsPath(flake)) || !s.dir(s.TagPath(tag)) ||
+		s.file(s.TagPath(tag)+"/"+flake) {
 		return
 	}
 
-- 
GitLab