// --------------------------------------------------------- public AddonDupSet(AddonBasicInfo pAddonBasicInfo) { Name = pAddonBasicInfo.Name; Publisher = pAddonBasicInfo.Publisher; QualifiedName = $"{Publisher}.{Name}"; FingerPrint = GetFingerPrint(pAddonBasicInfo); }
private AddonDupSet FindDupSet(List <AddonDupSet> pDupSets, AddonBasicInfo pAddonBasicInfo) { foreach (AddonDupSet set in pDupSets) { if (set.IsMatch(pAddonBasicInfo)) { return(set); } } return(null); }
public bool IsMatch(AddonBasicInfo pAddonBasicInfo) { if (FingerPrint == null) { return(false); } string addonFingerPrint = GetFingerPrint(pAddonBasicInfo); if (addonFingerPrint == null) { return(false); } return(addonFingerPrint == FingerPrint); }
// Used for identifying duplicates public static string GetFingerPrint(AddonBasicInfo pAddonBasicInfo) { StringBuilder fingerprintBuilder = new StringBuilder(); if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.Fingerprint)) { return(pAddonBasicInfo.AddonPackage.FingerPrint); } if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.RecompilableFlag)) { fingerprintBuilder.Append($"R:{pAddonBasicInfo.AddonPackage.Recompilable}^"); } if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.Publisher)) { fingerprintBuilder.Append($"P:{pAddonBasicInfo.AddonPackage.Publisher}^"); } if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.Name)) { fingerprintBuilder.Append($"N:{pAddonBasicInfo.AddonPackage.Name}^"); } if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.LastCompiled)) { fingerprintBuilder.Append($"LC:{pAddonBasicInfo.AddonPackage.LastCompiled:s}^"); } if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.MeshDataSize)) { if (!pAddonBasicInfo.AddonPackage.MeshDataSizeMbytes.HasValue) { fingerprintBuilder.Append("M:_^"); } else { fingerprintBuilder.Append($"M:{pAddonBasicInfo.AddonPackage.MeshDataSizeMbytes.Value:F5}^"); } } if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.AssetCount)) { AddonAssetSummary summary = pAddonBasicInfo.AddonPackage.AssetSummary; fingerprintBuilder.Append( $"A:{summary.Animations}_{summary.Bodyparts}_{summary.Decals}_{summary.CuttingRoomAssets}_{summary.Materials}_{summary.Props}:{summary.PropVariants}_{summary.SkyTextures}_{summary.Sounds}_{summary.SpecialEffects}_{summary.OtherAssets}_{summary.StartMovies}_{summary.Stocks}_{summary.Verbs}^"); } if (DuplicateDetectionFlag.HasFlag(DuplicateDetectionFlag.TotalFiles)) { fingerprintBuilder.Append($"F:{pAddonBasicInfo.AddonPackage?.FileSummaryInfo.TotalFiles ?? 0}^"); } return(fingerprintBuilder.ToString()); }