mirror of
https://github.com/mudler/luet.git
synced 2025-07-14 15:44:17 +00:00
Use table lookup for checking addition files
This commit is contained in:
parent
bdcf26401c
commit
1b1ab6225c
@ -46,18 +46,42 @@ func ExtractDeltaFiles(
|
|||||||
includeRegexp := compileRegexes(includes)
|
includeRegexp := compileRegexes(includes)
|
||||||
excludeRegexp := compileRegexes(excludes)
|
excludeRegexp := compileRegexes(excludes)
|
||||||
|
|
||||||
|
additions := map[string]interface{}{}
|
||||||
|
for _, a := range d.Additions {
|
||||||
|
additions[a.Name] = nil
|
||||||
|
}
|
||||||
return func(h *tar.Header) (bool, error) {
|
return func(h *tar.Header) (bool, error) {
|
||||||
fileName := filepath.Join(string(os.PathSeparator), h.Name)
|
fileName := filepath.Join(string(os.PathSeparator), h.Name)
|
||||||
ctx.Debug("Includes", includes)
|
_, exists := additions[h.Name]
|
||||||
ctx.Debug("Excludes", excludes)
|
if !exists {
|
||||||
ctx.Debug("Additions", d.Additions)
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case len(includes) == 0 && len(excludes) != 0:
|
case len(includes) == 0 && len(excludes) != 0:
|
||||||
for _, a := range d.Additions {
|
for _, i := range excludeRegexp {
|
||||||
if h.Name == a.Name {
|
if i.MatchString(filepath.Join(string(os.PathSeparator), h.Name)) &&
|
||||||
for _, i := range excludeRegexp {
|
fileName == filepath.Join(string(os.PathSeparator), h.Name) {
|
||||||
if i.MatchString(filepath.Join(string(os.PathSeparator), a.Name)) &&
|
return false, nil
|
||||||
fileName == filepath.Join(string(os.PathSeparator), a.Name) {
|
}
|
||||||
|
}
|
||||||
|
ctx.Debug("Adding name", fileName)
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
case len(includes) > 0 && len(excludes) == 0:
|
||||||
|
for _, i := range includeRegexp {
|
||||||
|
if i.MatchString(filepath.Join(string(os.PathSeparator), h.Name)) && fileName == filepath.Join(string(os.PathSeparator), h.Name) {
|
||||||
|
ctx.Debug("Adding name", fileName)
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
case len(includes) != 0 && len(excludes) != 0:
|
||||||
|
for _, i := range includeRegexp {
|
||||||
|
if i.MatchString(filepath.Join(string(os.PathSeparator), h.Name)) && fileName == filepath.Join(string(os.PathSeparator), h.Name) {
|
||||||
|
for _, e := range excludeRegexp {
|
||||||
|
if e.MatchString(fileName) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,43 +90,11 @@ func ExtractDeltaFiles(
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
|
||||||
case len(includes) > 0 && len(excludes) == 0:
|
|
||||||
for _, a := range d.Additions {
|
|
||||||
for _, i := range includeRegexp {
|
|
||||||
if i.MatchString(filepath.Join(string(os.PathSeparator), a.Name)) && fileName == filepath.Join(string(os.PathSeparator), a.Name) {
|
|
||||||
ctx.Debug("Adding name", fileName)
|
|
||||||
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
case len(includes) != 0 && len(excludes) != 0:
|
|
||||||
for _, a := range d.Additions {
|
|
||||||
for _, i := range includeRegexp {
|
|
||||||
if i.MatchString(filepath.Join(string(os.PathSeparator), a.Name)) && fileName == filepath.Join(string(os.PathSeparator), a.Name) {
|
|
||||||
for _, e := range excludeRegexp {
|
|
||||||
if e.MatchString(fileName) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx.Debug("Adding name", fileName)
|
|
||||||
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false, nil
|
return false, nil
|
||||||
default:
|
default:
|
||||||
for _, a := range d.Additions {
|
ctx.Debug("Adding name", fileName)
|
||||||
if fileName == filepath.Join(string(os.PathSeparator), a.Name) {
|
return true, nil
|
||||||
ctx.Debug("Adding name", fileName)
|
|
||||||
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user