protected override void OnVisitFolder(IProgressStatus monitor, string path, string domain, bool recursive) { if (usePreScanDataFiles) { var scanDataIndex = AddinScanDataIndex.LoadFromFolder(monitor, path); if (scanDataIndex != null) { foreach (var file in scanDataIndex.Assemblies) { index.AddAssemblyLocation(file); } return; } } base.OnVisitFolder(monitor, path, domain, recursive); }
protected override void OnVisitFolder(IProgressStatus monitor, string path, string domain, bool recursive) { if (path == rootFolder) { // Create an index scanDataIndex = new AddinScanDataIndex(); base.OnVisitFolder(monitor, path, domain, recursive); // Scan the files after visiting the folder tree. At this point the assembly index will be complete // and will be able to resolve assemblies during the add-in scan foreach (var file in foundFiles) { if (scanner.ScanConfigAssemblies(monitor, file, ScanContext, out var config) && config != null) { StoreScanDataFile(monitor, file, config); } } foreach (var file in foundAssemblies) { if (scanner.ScanAssembly(monitor, file, ScanContext, out var config) && config != null) { StoreScanDataFile(monitor, file, config); } // The index contains a list of all assemblies, no matter if they are add-ins or not scanDataIndex.Assemblies.Add(file); } foundFiles.Clear(); foundAssemblies.Clear(); scanDataIndex.SaveToFolder(path); scanDataIndex = null; } else { base.OnVisitFolder(monitor, path, domain, recursive); } }
protected override void OnVisitFolder(IProgressStatus monitor, string path, string domain, bool recursive) { AddinScanFolderInfo folderInfo; if (!database.GetFolderInfoForPath(monitor, path, out folderInfo)) { // folderInfo file was corrupt. // Just in case, we are going to regenerate all relation data. if (!FileSystem.DirectoryExists(path)) { scanResult.RegenerateRelationData = true; } } else { // Directory is included but it doesn't exist. Ignore it. if (folderInfo == null && !FileSystem.DirectoryExists(path)) { return; } } // if domain is null it means that a new domain has to be created. // Look for an add-in scan data index file. If it is present, it means the folder has been pre-scanned var dirScanDataIndex = AddinScanDataIndex.LoadFromFolder(monitor, path); if (dirScanDataIndex != null && scanResult.CleanGeneratedAddinScanDataFiles) { // Remove any existing dir.addindata if data is being generated dirScanDataIndex.Delete(); dirScanDataIndex = null; } bool sharedFolder = domain == AddinDatabase.GlobalDomain; bool isNewFolder = folderInfo == null; bool folderHasIndex = dirScanDataIndex != null; if (isNewFolder) { // No folder info. It is the first time this folder is scanned. // There is no need to store this object if the folder does not // contain add-ins. folderInfo = new AddinScanFolderInfo(path); folderInfo.FolderHasScanDataIndex = folderHasIndex; } else if (folderInfo.FolderHasScanDataIndex != folderHasIndex) { // A scan data index appeared or disappeared. The information in folderInfo is not reliable. // Update the folder info and regenerate everything. scanResult.RegenerateRelationData = true; folderInfo.Reset(); scanResult.RegisterModifiedFolderInfo(folderInfo); folderInfo.FolderHasScanDataIndex = folderHasIndex; } if (!sharedFolder && (folderInfo.SharedFolder || folderInfo.Domain != domain)) { // If the folder already has a domain, reuse it if (domain == null && folderInfo.RootsDomain != null && folderInfo.RootsDomain != AddinDatabase.GlobalDomain) { domain = folderInfo.RootsDomain; } else if (domain == null) { folderInfo.Domain = domain = database.GetUniqueDomainId(); scanResult.RegenerateRelationData = true; } else { folderInfo.Domain = domain; if (!isNewFolder) { // Domain has changed. Update the folder info and regenerate everything. scanResult.RegenerateRelationData = true; scanResult.RegisterModifiedFolderInfo(folderInfo); } } } else if (!folderInfo.SharedFolder && sharedFolder) { scanResult.RegenerateRelationData = true; } folderInfo.SharedFolder = sharedFolder; // If there is no domain assigned to the host, get one now if (scanResult.Domain == AddinDatabase.UnknownDomain) { scanResult.Domain = domain; } // Discard folders not belonging to the required domain if (scanResult.Domain != null && domain != scanResult.Domain && domain != AddinDatabase.GlobalDomain) { return; } if (monitor.LogLevel > 1) { monitor.Log("Checking: " + path); } if (dirScanDataIndex != null) { // Instead of scanning the folder, just register the files in the index foreach (var file in dirScanDataIndex.Files) { RegisterFileToScan(monitor, file.FileName, folderInfo, file); } foreach (var file in dirScanDataIndex.Assemblies) { scanResult.AssemblyIndex.AddAssemblyLocation(file); } } else { currentFolderInfo = folderInfo; base.OnVisitFolder(monitor, path, domain, recursive); if (!FileSystem.DirectoryExists(path)) { // The folder has been deleted. All add-ins defined in that folder should also be deleted. scanResult.RegenerateRelationData = true; scanResult.ChangesFound = true; if (scanResult.CheckOnly) { return; } database.DeleteFolderInfo(monitor, folderInfo); } } // Look for deleted add-ins. UpdateDeletedAddins(monitor, folderInfo); }