mirror of
https://github.com/mudler/luet.git
synced 2025-08-01 07:21:21 +00:00
Update revdeps table while populating Cache
When we cycle, we don't necessarly have all the packages into the DB yet. With this change, luet annotates the reverse dependency without any version, and we try to update revdeps table when new items gets added, by checking the version required in the selector. Thanks to @joostruis for noticing the issue
This commit is contained in:
parent
38c9540a1d
commit
0652fce55e
@ -213,6 +213,25 @@ func (db *InMemoryDatabase) populateCaches(p Package) {
|
||||
db.CacheNoVersion[p.GetPackageName()] = make(map[string]interface{})
|
||||
}
|
||||
db.CacheNoVersion[p.GetPackageName()][p.GetVersion()] = nil
|
||||
|
||||
// Updating Revdeps
|
||||
// Given that when we populate the cache we don't have the full db at hand
|
||||
// We cycle over reverse dependency of a package to update their entry if they are matching
|
||||
// the version selector
|
||||
toUpdate, ok := db.RevDepsDatabase[pd.GetPackageName()]
|
||||
if ok {
|
||||
for _, pp := range toUpdate {
|
||||
for _, re := range pp.GetRequires() {
|
||||
if match, _ := pd.VersionMatchSelector(re.GetVersion(), nil); match {
|
||||
_, ok = db.RevDepsDatabase[pd.GetFingerPrint()]
|
||||
if !ok {
|
||||
db.RevDepsDatabase[pd.GetFingerPrint()] = make(map[string]Package)
|
||||
}
|
||||
db.RevDepsDatabase[pd.GetFingerPrint()][pp.GetFingerPrint()] = pp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db.Unlock()
|
||||
|
||||
for _, re := range pd.GetRequires() {
|
||||
@ -225,12 +244,23 @@ func (db *InMemoryDatabase) populateCaches(p Package) {
|
||||
db.RevDepsDatabase[pa.GetFingerPrint()] = make(map[string]Package)
|
||||
}
|
||||
db.RevDepsDatabase[pa.GetFingerPrint()][pd.GetFingerPrint()] = pd
|
||||
_, ok = db.RevDepsDatabase[pa.GetPackageName()]
|
||||
if !ok {
|
||||
db.RevDepsDatabase[pa.GetPackageName()] = make(map[string]Package)
|
||||
}
|
||||
db.RevDepsDatabase[pa.GetPackageName()][pd.GetPackageName()] = pd
|
||||
}
|
||||
_, ok := db.RevDepsDatabase[re.GetFingerPrint()]
|
||||
if !ok {
|
||||
db.RevDepsDatabase[re.GetFingerPrint()] = make(map[string]Package)
|
||||
}
|
||||
db.RevDepsDatabase[re.GetFingerPrint()][pd.GetFingerPrint()] = pd
|
||||
_, ok = db.RevDepsDatabase[re.GetPackageName()]
|
||||
if !ok {
|
||||
db.RevDepsDatabase[re.GetPackageName()] = make(map[string]Package)
|
||||
}
|
||||
db.RevDepsDatabase[re.GetPackageName()][pd.GetPackageName()] = pd
|
||||
|
||||
db.Unlock()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user