mirror of
https://github.com/munki/munki.git
synced 2026-05-21 21:58:31 -05:00
Add an ApplicationInventory singleton to cache application invemory data so we don't re-generate it all the time
This commit is contained in:
@@ -141,7 +141,7 @@ func spApplicationData() async -> PlistDict {
|
||||
return applicationData
|
||||
}
|
||||
|
||||
func appData() -> [[String: String]] {
|
||||
func getAppData() -> [[String: String]] {
|
||||
// Gets info on currently installed apps.
|
||||
// Returns a list of dicts containing path, name, version and bundleid
|
||||
|
||||
@@ -192,6 +192,31 @@ func appData() -> [[String: String]] {
|
||||
return applicationData
|
||||
}
|
||||
|
||||
class ApplicationInventory {
|
||||
// a Singleton class for application inventory info, since it's expensive
|
||||
// to generate
|
||||
static let shared = ApplicationInventory()
|
||||
|
||||
var inventory: [[String: String]]
|
||||
|
||||
private init() {
|
||||
inventory = getAppData()
|
||||
}
|
||||
|
||||
func get() -> [[String: String]] {
|
||||
return inventory
|
||||
}
|
||||
|
||||
func rescan() {
|
||||
// force a rescan of app inventory
|
||||
inventory = getAppData()
|
||||
}
|
||||
}
|
||||
|
||||
func appData() -> [[String: String]] {
|
||||
return ApplicationInventory.shared.get()
|
||||
}
|
||||
|
||||
func filteredAppData() -> [[String: String]] {
|
||||
// Returns a filtered version of app_data, filtering out apps in user
|
||||
// home directories for use by compare_application_version()
|
||||
|
||||
Reference in New Issue
Block a user