Avoid creating snapshots repeatedly
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
This commit is contained in:
parent
bbeaab5ee3
commit
df8ece5a41
@ -69,7 +69,7 @@ func ApplyLayer(snapshots snapshot.Snapshotter, mounter Mounter, rd io.Reader, p
|
|||||||
digester := digest.Canonical.Digester() // used to calculate diffID.
|
digester := digest.Canonical.Digester() // used to calculate diffID.
|
||||||
rd = io.TeeReader(rd, digester.Hash())
|
rd = io.TeeReader(rd, digester.Hash())
|
||||||
|
|
||||||
if _, err := archive.Apply(context.Background(), key, rd); err != nil {
|
if _, err := archive.Apply(context.Background(), dir, rd); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ func ApplyLayer(snapshots snapshot.Snapshotter, mounter Mounter, rd io.Reader, p
|
|||||||
chainID = identity.ChainID([]digest.Digest{parent, chainID})
|
chainID = identity.ChainID([]digest.Digest{parent, chainID})
|
||||||
}
|
}
|
||||||
if _, err := snapshots.Stat(ctx, chainID.String()); err == nil {
|
if _, err := snapshots.Stat(ctx, chainID.String()); err == nil {
|
||||||
return diffID, nil //TODO: call snapshots.Remove(ctx, key) once implemented
|
return diffID, snapshots.Remove(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
return diffID, snapshots.Commit(ctx, chainID.String(), key)
|
return diffID, snapshots.Commit(ctx, chainID.String(), key)
|
||||||
|
Loading…
Reference in New Issue
Block a user