@@ -179,8 +179,14 @@ func (r *Syncer) storeRepo(checksumMap map[string]XMLChecksum) (err error) {
179
179
downloadCount := len (packagesToDownload )
180
180
log .Printf ("Downloading %v packages...\n " , downloadCount )
181
181
for i , pack := range packagesToDownload {
182
- description := fmt .Sprintf ("(%v/%v) %v" , i + 1 , downloadCount , path .Base (pack .Location .Href ))
183
- err = r .downloadStoreApply (pack .Location .Href , pack .Checksum .Checksum , description , hashMap [pack .Checksum .Type ], util .Nop )
182
+ // we need to escape package names because some CDN, proxies (...) are not perfectly RFC 3986 compliant
183
+ // in such cases characters like '+' (which are common in c++ pkgs) will assume a different meaning
184
+ name := path .Base (pack .Location .Href )
185
+ escapedName := url .QueryEscape (name )
186
+ relativeURL := strings .TrimSuffix (pack .Location .Href , name ) + escapedName
187
+
188
+ description := fmt .Sprintf ("(%v/%v) %v" , i + 1 , downloadCount , name )
189
+ err = r .downloadStoreApply (relativeURL , pack .Checksum .Checksum , description , hashMap [pack .Checksum .Type ], util .Nop )
184
190
if err != nil {
185
191
return err
186
192
}
@@ -207,13 +213,20 @@ func (r *Syncer) storeRepo(checksumMap map[string]XMLChecksum) (err error) {
207
213
func (r * Syncer ) downloadStoreApply (relativePath string , checksum string , description string , hash crypto.Hash , f util.ReaderConsumer ) error {
208
214
log .Printf ("Downloading %v..." , description )
209
215
210
- url := r .URL
211
- url .Path = path .Join (r .URL .Path , relativePath )
212
- body , err := ReadURL (url .String ())
216
+ repoURL := r .URL
217
+ repoURL .Path = path .Join (repoURL .Path , relativePath )
218
+ finalURL := fmt .Sprintf ("%s://%s%s" , repoURL .Scheme , repoURL .Host , repoURL .Path )
219
+
220
+ body , err := ReadURL (finalURL )
221
+ if err != nil {
222
+ return err
223
+ }
224
+ // unescape to preserve original pkg name
225
+ storagePath , err := url .QueryUnescape (relativePath )
213
226
if err != nil {
214
227
return err
215
228
}
216
- return util .Compose (r .storage .StoringMapper (relativePath , checksum , hash ), f )(body )
229
+ return util .Compose (r .storage .StoringMapper (storagePath , checksum , hash ), f )(body )
217
230
}
218
231
219
232
// processMetadata stores the repo metadata and returns a list of package file
0 commit comments