Basic global hash whitelist
This commit is contained in:
@@ -73,10 +73,23 @@ func GetDuplicates(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Extract all hashes from source addon files
|
||||
// Get all whitelisted hashes
|
||||
var whitelistedHashes []string
|
||||
if err := initializers.DB.Model(&models.WhitelistedHash{}).Pluck("hash", &whitelistedHashes).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch whitelisted hashes"})
|
||||
return
|
||||
}
|
||||
|
||||
// Create a map for faster lookup
|
||||
whitelistMap := make(map[string]bool)
|
||||
for _, hash := range whitelistedHashes {
|
||||
whitelistMap[hash] = true
|
||||
}
|
||||
|
||||
// Extract all hashes from source addon files, excluding whitelisted ones
|
||||
var sourceHashes []string
|
||||
for _, file := range sourceAddon.AddonFiles {
|
||||
if file.Hash != "" {
|
||||
if file.Hash != "" && !whitelistMap[file.Hash] {
|
||||
sourceHashes = append(sourceHashes, file.Hash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user