mirror of
https://github.com/munki/munki.git
synced 2026-05-25 15:48:42 -05:00
Addresses #1267 where removals might consider/process the same item multiple times
This commit is contained in:
@@ -177,18 +177,28 @@ func getAllItemsWithName(_ name: String, catalogList: [String]) -> [PlistDict] {
|
||||
let nameTable = catalogDB["named"] as? CatalogDBTable,
|
||||
let versionsDict = nameTable[itemName]
|
||||
{
|
||||
var indexesToAdd: Set<Int> = []
|
||||
for (version, indexes) in versionsDict {
|
||||
if version == "latest" {
|
||||
continue
|
||||
}
|
||||
indexesToAdd.formUnion(indexes)
|
||||
}
|
||||
for index in indexesToAdd {
|
||||
let item = items[index]
|
||||
let version = item["version"] as? String ?? "<unknown>"
|
||||
display.debug1("Adding item \(itemName), version \(version) from catalog \(catalogName)...")
|
||||
itemList.append(item)
|
||||
for index in indexes {
|
||||
do {
|
||||
let item = items[index]
|
||||
// need to compare encoded representations because
|
||||
// PlistDict (aka [String: Any] is not hashable
|
||||
let itemEncoded = try plistToData(item)
|
||||
let alreadyAddedItem = try itemList.contains(
|
||||
where: { try plistToData($0) == itemEncoded })
|
||||
if !alreadyAddedItem {
|
||||
let version = item["version"] as? String ?? "<unknown>"
|
||||
display.debug1("Adding item \(itemName), version \(version) from catalog \(catalogName)...")
|
||||
itemList.append(item)
|
||||
}
|
||||
} catch {
|
||||
// error converting an item to plistData. Really unlikely,
|
||||
// but if it happens we just don't add the item and continue on
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user