Skip to content

Commit

Permalink
use docker lock less exaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
Equanox committed Jan 5, 2023
1 parent 1de11ba commit 49f9683
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions pkg/dockermobyutil/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,10 @@ func (r *R) ImageExists(image string) (bool, error) {
}

func (r *R) ImageHash(image string) (string, error) {
r.mutex.Lock()
summaries, err := r.client.ImageList(context.Background(), types.ImageListOptions{All: false})
if err != nil {
r.mutex.Unlock()
return "", err
}
r.mutex.Unlock()

var selected types.ImageSummary
for _, s := range summaries {
Expand All @@ -98,13 +95,10 @@ func (r *R) ImageHash(image string) (string, error) {
}

func (r *R) imageSaveToPath(image string, savedir string) (pathToArchive string, _ error) {
r.mutex.Lock()
reader, err := r.client.ImageSave(context.Background(), []string{image})
if err != nil {
r.mutex.Unlock()
return "", err
}
r.mutex.Unlock()
defer reader.Close()

body, err := ioutil.ReadAll(reader)
Expand Down Expand Up @@ -135,8 +129,6 @@ func (r *R) ImageSave(image string) (pathToArchive string, _ error) {

// ImageRemove from registry
func (r *R) ImageRemove(imageID string) error {
r.mutex.Lock()
defer r.mutex.Unlock()
options := types.ImageRemoveOptions{
Force: true,
PruneChildren: true,
Expand Down Expand Up @@ -169,8 +161,6 @@ func (r *R) ImageLoad(imgpath string) error {

// ImageLoad from tar archive
func (r *R) ImageTag(src string, target string) error {
r.mutex.Lock()
defer r.mutex.Unlock()
return r.client.ImageTag(context.Background(), src, target)
}

Expand Down

0 comments on commit 49f9683

Please sign in to comment.