Skip to content

Commit e244369

Browse files
committed
Fix hash comparison bug causing unnecessary redownloads
1 parent d3d06b1 commit e244369

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

push.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ func push(cfg *config.PushConfig) error {
105105
s3FileName := fileName + ".enc"
106106
s3Key := s3client.BuildKey(cfg.S3.Prefix, s3FileName)
107107

108-
newHashes[s3FileName] = localHashStr
108+
newHashes[fileName] = localHashStr
109109

110110
// Check if hash matches
111-
if existingHash, ok := existingHashes[s3FileName]; ok && existingHash == localHashStr {
111+
if existingHash, ok := existingHashes[fileName]; ok && existingHash == localHashStr {
112112
continue
113113
}
114114

@@ -133,8 +133,18 @@ func push(cfg *config.PushConfig) error {
133133
}
134134
}
135135

136-
// Upload updated hashes file if anything changed
137-
if uploaded {
136+
// Upload updated hashes file if it changed
137+
hashesChanged := len(newHashes) != len(existingHashes)
138+
if !hashesChanged {
139+
for k, v := range newHashes {
140+
if existingHashes[k] != v {
141+
hashesChanged = true
142+
break
143+
}
144+
}
145+
}
146+
147+
if hashesChanged {
138148
hashesJSON, err := json.Marshal(newHashes)
139149
if err != nil {
140150
return fmt.Errorf("marshal hashes: %w", err)

0 commit comments

Comments
 (0)