dnfjson: Cleanup old distro cache dirs
This adds a function, CleanupOldCacheDirs, that checks the dirs under /var/cache/osbuild-composer/rpmmd/ and removes files and directories that don't match the current list of supported distros. This will clean up the cache from old releases as the are retired, and will also cleanup the old top level cache directory structure after an upgrade. NOTE: This function does not return errors, any real problems it encounters will also be caught by the cache initialization code and handled there.
This commit is contained in:
parent
8f20b550ea
commit
f731ab53d0
3 changed files with 109 additions and 10 deletions
|
|
@ -71,6 +71,9 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string) (*Compos
|
|||
c.distros = distroregistry.NewDefault()
|
||||
logrus.Infof("Loaded %d distros", len(c.distros.List()))
|
||||
|
||||
// Clean up the cache, removes unknown distros and files
|
||||
dnfjson.CleanupOldCacheDirs(path.Join(c.cacheDir, "rpmmd"), c.distros.List())
|
||||
|
||||
c.solver = dnfjson.NewBaseSolver(path.Join(c.cacheDir, "rpmmd"))
|
||||
c.solver.SetDNFJSONPath(c.config.DNFJson)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue