Skip to content

Commit 4f1bfca

Browse files
committed
don't get file when checksum of destination is valid
1 parent 7ee49f6 commit 4f1bfca

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

client.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,24 @@ func (c *Client) Get() error {
248248
// If we're not downloading a directory, then just download the file
249249
// and return.
250250
if mode == ClientModeFile {
251-
err := g.GetFile(dst, u)
252-
if err != nil {
253-
return err
254-
}
255-
251+
getFile := true
256252
if checksumHash != nil {
257-
if err := checksum(dst, checksumHash, checksumValue); err != nil {
253+
if err := checksum(dst, checksumHash, checksumValue); err == nil {
254+
// don't get the file if the checksum of dst is correct
255+
getFile = false
256+
}
257+
}
258+
if getFile {
259+
err := g.GetFile(dst, u)
260+
if err != nil {
258261
return err
259262
}
263+
264+
if checksumHash != nil {
265+
if err := checksum(dst, checksumHash, checksumValue); err != nil {
266+
return err
267+
}
268+
}
260269
}
261270

262271
if decompressor != nil {

0 commit comments

Comments
 (0)