@@ -101,20 +101,31 @@ var (
101
101
Noarch : "all" ,
102
102
},
103
103
}
104
- Legacy bool
104
+ SkipLegacy bool
105
105
)
106
106
107
107
// Syncer syncs repos from an HTTP source to a Storage
108
108
type Syncer struct {
109
109
// URL of the repo this syncer syncs
110
110
URL url.URL
111
- archs map [string ]bool
112
111
storage Storage
113
112
}
114
113
114
+ // Decision encodes what to do with a file
115
+ type Decision int
116
+
117
+ const (
118
+ // Download means the Syncer will download a file
119
+ Download Decision = iota
120
+ // Recycle means the Syncer will copy an existing file without downloading
121
+ Recycle
122
+ // Skip means the Syncer detected an already-existing file and has nothing to do
123
+ Skip
124
+ )
125
+
115
126
// NewSyncer creates a new Syncer
116
- func NewSyncer (url url.URL , archs map [ string ] bool , storage Storage ) * Syncer {
117
- return & Syncer {url , archs , storage }
127
+ func NewSyncer (url url.URL , storage Storage ) * Syncer {
128
+ return & Syncer {url , storage }
118
129
}
119
130
120
131
// StoreRepo stores an HTTP repo in a Storage, automatically retrying in case of recoverable errors
@@ -190,11 +201,6 @@ func (r *Syncer) storeRepo(checksumMap map[string]XMLChecksum) (err error) {
190
201
return
191
202
}
192
203
193
- // downloadStore downloads a repo-relative path into a file
194
- func (r * Syncer ) downloadStore (path string , description string ) error {
195
- return r .downloadStoreApply (path , "" , description , 0 , util .Nop )
196
- }
197
-
198
204
// downloadStoreApply downloads a repo-relative path into a file, while applying a ReaderConsumer
199
205
func (r * Syncer ) downloadStoreApply (relativePath string , checksum string , description string , hash crypto.Hash , f util.ReaderConsumer ) error {
200
206
log .Printf ("Downloading %v..." , description )
@@ -232,6 +238,7 @@ func (r *Syncer) processMetadata(checksumMap map[string]XMLChecksum) (packagesTo
232
238
log .Printf (data [i ].Location .Href )
233
239
metadataLocation := data [i ].Location .Href
234
240
metadataChecksum := data [i ].Checksum
241
+
235
242
decision := r .decide (metadataLocation , metadataChecksum , checksumMap )
236
243
switch decision {
237
244
case Download :
@@ -404,39 +411,30 @@ func (r *Syncer) processPrimary(path string, checksumMap map[string]XMLChecksum,
404
411
if err != nil {
405
412
return
406
413
}
414
+
407
415
compType := strings .Trim (filepath .Ext (path ), "." )
408
416
primary , err := repoType .DecodePackages (reader , compType )
409
417
if err != nil {
410
418
return
411
419
}
412
420
413
- allArchs := len (r .archs ) == 0
414
421
for _ , pack := range primary .Packages {
415
- if allArchs || pack .Arch == repoType .Noarch || r .archs [pack .Arch ] || (r .archs ["i586" ] && pack .Arch == "i686" ) || (Legacy && (r .archs ["x86_64" ] && (pack .Arch == "i586" || pack .Arch == "i686" ))) {
416
- decision := r .decide (pack .Location .Href , pack .Checksum , checksumMap )
417
- switch decision {
418
- case Download :
419
- packagesToDownload = append (packagesToDownload , pack )
420
- case Recycle :
421
- packagesToRecycle = append (packagesToRecycle , pack )
422
- }
422
+ if SkipLegacy && (pack .Arch == "i586" || pack .Arch == "i686" ) {
423
+ fmt .Println ("Skipping legacy package:" , pack .Location .Href )
424
+ continue
425
+ }
426
+
427
+ decision := r .decide (pack .Location .Href , pack .Checksum , checksumMap )
428
+ switch decision {
429
+ case Download :
430
+ packagesToDownload = append (packagesToDownload , pack )
431
+ case Recycle :
432
+ packagesToRecycle = append (packagesToRecycle , pack )
423
433
}
424
434
}
425
435
return
426
436
}
427
437
428
- // Decision encodes what to do with a file
429
- type Decision int
430
-
431
- const (
432
- // Download means the Syncer will download a file
433
- Download Decision = iota
434
- // Recycle means the Syncer will copy an existing file without downloading
435
- Recycle
436
- // Skip means the Syncer detected an already-existing file and has nothing to do
437
- Skip
438
- )
439
-
440
438
func (r * Syncer ) decide (location string , checksum XMLChecksum , checksumMap map [string ]XMLChecksum ) Decision {
441
439
previousChecksum , foundInChecksumMap := checksumMap [location ]
442
440
0 commit comments