diff --git a/image/helpers.go b/image/helpers.go
index 828887ee8..d3e6319c0 100644
--- a/image/helpers.go
+++ b/image/helpers.go
@@ -22,6 +22,7 @@ package image
// TODO: put these in appropriate package(s) once they are clarified a bit more
import (
+ "crypto"
"encoding/json"
"fmt"
"os"
@@ -31,6 +32,7 @@ import (
"github.com/snapcore/snapd/asserts"
"github.com/snapcore/snapd/asserts/snapasserts"
+ "github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/overlord/auth"
"github.com/snapcore/snapd/progress"
"github.com/snapcore/snapd/release"
@@ -144,6 +146,14 @@ func (tsto *ToolingStore) DownloadSnap(name string, revision snap.Revision, opts
baseName := filepath.Base(snap.MountFile())
targetFn = filepath.Join(targetDir, baseName)
+ // check if we already have the right file
+ if osutil.FileExists(targetFn) {
+ sha3_384Dgst, size, err := osutil.FileDigest(targetFn, crypto.SHA3_384)
+ if err == nil && size == uint64(snap.DownloadInfo.Size) && fmt.Sprintf("%x", sha3_384Dgst) == snap.DownloadInfo.Sha3_384 {
+ return targetFn, snap, nil
+ }
+ }
+
pb := progress.MakeProgressBar()
defer pb.Finished()