Browse code

Fix the bug of tag a existed tag name of a repository.

Signed-off-by: Lei Jitang <leijitang@huawei.com>

Lei Jitang authored on 2014/09/30 17:57:17
Showing 2 changed files
... ...
@@ -124,7 +124,7 @@ func (b *BuilderJob) CmdBuild(job *engine.Job) engine.Status {
124 124
 	}
125 125
 
126 126
 	if repoName != "" {
127
-		b.Daemon.Repositories().Set(repoName, tag, id, false)
127
+		b.Daemon.Repositories().Set(repoName, tag, id, true)
128 128
 	}
129 129
 	return engine.StatusOK
130 130
 }
... ...
@@ -218,11 +218,11 @@ func (store *TagStore) Set(repoName, tag, imageName string, force bool) error {
218 218
 	var repo Repository
219 219
 	if r, exists := store.Repositories[repoName]; exists {
220 220
 		repo = r
221
+		if old, exists := store.Repositories[repoName][tag]; exists && !force {
222
+			return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", tag, old)
223
+		}
221 224
 	} else {
222 225
 		repo = make(map[string]string)
223
-		if old, exists := store.Repositories[repoName]; exists && !force {
224
-			return fmt.Errorf("Conflict: Tag %s:%s is already set to %s", repoName, tag, old)
225
-		}
226 226
 		store.Repositories[repoName] = repo
227 227
 	}
228 228
 	repo[tag] = img.ID