mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Merge pull request #134 from safing/feature/empty-index-support
Improve empty index support
This commit is contained in:
commit
49c21c83f8
2 changed files with 23 additions and 23 deletions
|
@ -132,7 +132,7 @@ func (reg *ResourceRegistry) loadIndexFile(idx Index) error {
|
|||
}
|
||||
|
||||
if len(releases) == 0 {
|
||||
log.Warningf("%s: index %s is empty", reg.Name, idx.Path)
|
||||
log.Debugf("%s: index %s is empty", reg.Name, idx.Path)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -59,30 +59,30 @@ func (reg *ResourceRegistry) downloadIndex(ctx context.Context, client *http.Cli
|
|||
return fmt.Errorf("failed to parse index %s: %w", idx.Path, err)
|
||||
}
|
||||
|
||||
// check for content
|
||||
if len(newIndexData) == 0 {
|
||||
return fmt.Errorf("index %s is empty", idx.Path)
|
||||
}
|
||||
|
||||
// Check if all resources are within the indexes' authority.
|
||||
authoritativePath := path.Dir(idx.Path) + "/"
|
||||
if authoritativePath == "./" {
|
||||
// Fix path for indexes at the storage root.
|
||||
authoritativePath = ""
|
||||
}
|
||||
cleanedData := make(map[string]string, len(newIndexData))
|
||||
for key, version := range newIndexData {
|
||||
if strings.HasPrefix(key, authoritativePath) {
|
||||
cleanedData[key] = version
|
||||
} else {
|
||||
log.Warningf("%s: index %s oversteps it's authority by defining version for %s", reg.Name, idx.Path, key)
|
||||
// Add index data to registry.
|
||||
if len(newIndexData) > 0 {
|
||||
// Check if all resources are within the indexes' authority.
|
||||
authoritativePath := path.Dir(idx.Path) + "/"
|
||||
if authoritativePath == "./" {
|
||||
// Fix path for indexes at the storage root.
|
||||
authoritativePath = ""
|
||||
}
|
||||
cleanedData := make(map[string]string, len(newIndexData))
|
||||
for key, version := range newIndexData {
|
||||
if strings.HasPrefix(key, authoritativePath) {
|
||||
cleanedData[key] = version
|
||||
} else {
|
||||
log.Warningf("%s: index %s oversteps it's authority by defining version for %s", reg.Name, idx.Path, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add resources to registry
|
||||
err = reg.AddResources(cleanedData, false, true, idx.PreRelease)
|
||||
if err != nil {
|
||||
log.Warningf("%s: failed to add resources: %s", reg.Name, err)
|
||||
// add resources to registry
|
||||
err = reg.AddResources(cleanedData, false, true, idx.PreRelease)
|
||||
if err != nil {
|
||||
log.Warningf("%s: failed to add resources: %s", reg.Name, err)
|
||||
}
|
||||
} else {
|
||||
log.Debugf("%s: index %s is empty", reg.Name, idx.Path)
|
||||
}
|
||||
|
||||
// check if dest dir exists
|
||||
|
|
Loading…
Add table
Reference in a new issue