Skip to content

Commit

Permalink
Clean up the sync
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jan 13, 2025
1 parent 025a6e8 commit aa273b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"

"github.com/daocloud/crproxy/cache"
"github.com/daocloud/crproxy/internal/utils"
"github.com/distribution/reference"
"github.com/docker/distribution"
"github.com/docker/distribution/manifest/manifestlist"
Expand Down Expand Up @@ -134,6 +135,7 @@ func (c *SyncManager) Image(ctx context.Context, image string) error {

path := reference.Path(named)

host, path = utils.CorrectImage(host, path)
name := newNameWithoutDomain(named, path)

repo, err := client.NewRepository(name, "https://"+host, c.transport)
Expand Down Expand Up @@ -186,12 +188,14 @@ func (c *SyncManager) Image(ctx context.Context, image string) error {
}
defer f.Close()

c.logger.Info("start sync blob", "image", image, "digest", dgst, "platform", pf, "name", name)

if len(subCaches) == 1 {
n, err := subCaches[0].PutBlob(ctx, blob, f)
if err != nil {
return fmt.Errorf("put blob failed: %w", err)
}
c.logger.Info("sync blob", "image", image, "digest", dgst, "size", n, "platform", pf, "name", name)
c.logger.Info("finish sync blob", "image", image, "digest", dgst, "size", n, "platform", pf, "name", name)
return nil
}

Expand Down Expand Up @@ -224,7 +228,7 @@ func (c *SyncManager) Image(ctx context.Context, image string) error {

wg.Wait()

c.logger.Info("sync blob", "image", image, "digest", dgst, "platform", pf, "name", name, "size", n)
c.logger.Info("finish sync blob", "image", image, "digest", dgst, "size", n, "platform", pf, "name", name)
return nil
}

Expand Down

0 comments on commit aa273b7

Please sign in to comment.