Skip to content

Commit 73758d6

Browse files
Resumed artifact installation fails (#42)
[#41] Resumed artifact installation fails - fixed resuming of fully downloaded artifacts Signed-off-by: Georgi Boyvalenkov <Georgi.Boyvalenkov@bosch.io>
1 parent 071b39b commit 73758d6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/storage/download.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ func downloadArtifact(to string, artifact *Artifact, progress progressBytes, ser
101101

102102
func resume(to string, offset int64, artifact *Artifact, progress progressBytes, serverCert string, retryCount int,
103103
retryInterval time.Duration, done chan struct{}) (int64, error) {
104+
if offset == int64(artifact.Size) {
105+
logger.Infof("validating previously downloaded artifact: %s", to)
106+
if err := validate(to, artifact.HashType, artifact.HashValue); err == nil || retryCount == 0 {
107+
return 0, err
108+
}
109+
offset = 0 // retry download otherwise
110+
retryCount--
111+
time.Sleep(time.Duration(retryInterval))
112+
}
104113
// Send the HTTP request and get its response.
105114
source, remainingRetries, resumeSupported, err := openResource(artifact, offset, serverCert, retryCount, retryInterval)
106115
if err != nil {

0 commit comments

Comments
 (0)