Example #1
0
        public void ScanFolder(IProgressStatus monitor, string path, string domain, AddinScanResult scanResult)
        {
            path = Path.GetFullPath (path);

            // Avoid folders including each other
            if (!scanResult.VisitFolder (path))
                return;

            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 (!fs.DirectoryExists (path))
                    scanResult.RegenerateRelationData = true;
            } else {
                // Directory is included but it doesn't exist. Ignore it.
                if (folderInfo == null && !fs.DirectoryExists (path))
                    return;
            }

            // if domain is null it means that a new domain has to be created.

            bool sharedFolder = domain == AddinDatabase.GlobalDomain;
            bool isNewFolder = folderInfo == 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);
            }

            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 && !scanResult.LocateAssembliesOnly)
                monitor.Log ("Checking: " + path);

            if (fs.DirectoryExists (path))
            {
                IEnumerable<string> files = fs.GetFiles (path);

                // First of all, look for .addin files. Addin files must be processed before
                // assemblies, because they may add files to the ignore list (i.e., assemblies
                // included in .addin files won't be scanned twice).
                foreach (string file in files) {
                    if (file.EndsWith (".addin.xml") || file.EndsWith (".addin")) {
                        RegisterFileToScan (monitor, file, scanResult, folderInfo);
                    }
                }

                // Now scan assemblies. They can also add files to the ignore list.

                foreach (string file in files) {
                    string ext = Path.GetExtension (file).ToLower ();
                    if (ext == ".dll" || ext == ".exe") {
                        RegisterFileToScan (monitor, file, scanResult, folderInfo);
                        scanResult.AddAssemblyLocation (file);
                    }
                }

                // Finally scan .addins files

                foreach (string file in files) {
                    if (Path.GetExtension (file).EndsWith (".addins")) {
                        ScanAddinsFile (monitor, file, domain, scanResult);
                    }
                }
            }
            else if (!scanResult.LocateAssembliesOnly) {
                // 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);
            }

            if (scanResult.LocateAssembliesOnly)
                return;

            // Look for deleted add-ins.

            UpdateDeletedAddins (monitor, folderInfo, scanResult);
        }
        public void ScanFolder(IProgressStatus monitor, string path, AddinScanResult scanResult)
        {
            path = Util.GetFullPath(path);

            // Avoid folders including each other
            if (!scanResult.VisitFolder(path))
            {
                return;
            }

            if (monitor.VerboseLog && !scanResult.LocateAssembliesOnly)
            {
                monitor.Log("Checking: " + path);
            }

            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 (!Directory.Exists(path))
                {
                    scanResult.RegenerateRelationData = true;
                }
            }
            else
            {
                if (folderInfo == null && !Directory.Exists(path))
                {
                    return;
                }
            }

            if (folderInfo == null)
            {
                folderInfo = new AddinScanFolderInfo(path);
            }

            if (Directory.Exists(path))
            {
                foreach (string file in Directory.GetFiles(path))
                {
                    if (file.EndsWith(".addin.xml"))
                    {
                        RegisterFileToScan(monitor, file, scanResult, folderInfo);
                        continue;
                    }
                    switch (Path.GetExtension(file))
                    {
                    case ".dll":
                    case ".exe":
                        RegisterFileToScan(monitor, file, scanResult, folderInfo);
                        scanResult.AddAssemblyLocation(file);
                        break;

                    case ".addin":
                        RegisterFileToScan(monitor, file, scanResult, folderInfo);
                        break;

                    case ".addins":
                        ScanAddinsFile(monitor, file, scanResult);
                        break;
                    }
                }
            }
            else if (!scanResult.LocateAssembliesOnly)
            {
                // 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);
            }

            if (scanResult.LocateAssembliesOnly)
            {
                return;
            }

            // Look for deleted add-ins.

            UpdateDeletedAddins(monitor, folderInfo, scanResult);
        }
        public void ScanFolder(IProgressStatus monitor, string path, string domain, AddinScanResult scanResult)
        {
            path = Util.GetFullPath(path);

            // Avoid folders including each other
            if (!scanResult.VisitFolder(path))
            {
                return;
            }

            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 (!Directory.Exists(path))
                {
                    scanResult.RegenerateRelationData = true;
                }
            }
            else
            {
                // Directory is included but it doesn't exist. Ignore it.
                if (folderInfo == null && !Directory.Exists(path))
                {
                    return;
                }
            }

            // if domain is null it means that a new domain has to be created.

            bool sharedFolder = domain == AddinDatabase.GlobalDomain;
            bool isNewFolder  = folderInfo == 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);
            }

            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 && !scanResult.LocateAssembliesOnly)
            {
                monitor.Log("Checking: " + path);
            }

            if (Directory.Exists(path))
            {
                string[] files = Directory.GetFiles(path);

                // First of all, look for .addin files. Addin files must be processed before
                // assemblies, because they may add files to the ignore list (i.e., assemblies
                // included in .addin files won't be scanned twice).
                foreach (string file in files)
                {
                    if (file.EndsWith(".addin.xml") || file.EndsWith(".addin"))
                    {
                        RegisterFileToScan(monitor, file, scanResult, folderInfo);
                    }
                }

                // Now scan assemblies. They can also add files to the ignore list.

                foreach (string file in files)
                {
                    string ext = Path.GetExtension(file).ToLower();
                    if (ext == ".dll" || ext == ".exe")
                    {
                        RegisterFileToScan(monitor, file, scanResult, folderInfo);
                        scanResult.AddAssemblyLocation(file);
                    }
                }

                // Finally scan .addins files

                foreach (string file in files)
                {
                    if (Path.GetExtension(file).EndsWith(".addins"))
                    {
                        ScanAddinsFile(monitor, file, domain, scanResult);
                    }
                }
            }
            else if (!scanResult.LocateAssembliesOnly)
            {
                // 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);
            }

            if (scanResult.LocateAssembliesOnly)
            {
                return;
            }

            // Look for deleted add-ins.

            UpdateDeletedAddins(monitor, folderInfo, scanResult);
        }
		public void ScanFolder (IProgressStatus monitor, string path, AddinScanResult scanResult)
		{
			path = Util.GetFullPath (path);
			
			// Avoid folders including each other
			if (!scanResult.VisitFolder (path))
				return;
			
			if (monitor.VerboseLog && !scanResult.LocateAssembliesOnly)
				monitor.Log ("Checking: " + path);
			
			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 (!Directory.Exists (path))
					scanResult.RegenerateRelationData = true;
			} else {
				if (folderInfo == null && !Directory.Exists (path))
					return;
			}
			
			if (folderInfo == null)
				folderInfo = new AddinScanFolderInfo (path);
			
			if (Directory.Exists (path))
			{
				foreach (string file in Directory.GetFiles (path)) {
					if (file.EndsWith (".addin.xml")) {
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
						continue;
					}
					switch (Path.GetExtension (file)) {
					case ".dll":
					case ".exe":
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
						scanResult.AddAssemblyLocation (file);
						break;
					case ".addin":
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
						break;
					case ".addins":
						ScanAddinsFile (monitor, file, scanResult);
						break;
					}
				}
			}
			else if (!scanResult.LocateAssembliesOnly) {
				// 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);
			}
			
			if (scanResult.LocateAssembliesOnly)
				return;
			
			// Look for deleted add-ins.
			
			UpdateDeletedAddins (monitor, folderInfo, scanResult);
		}
		public void ScanFolder (IProgressStatus monitor, string path, string domain, AddinScanResult scanResult)
		{
			path = Util.GetFullPath (path);
			
			// Avoid folders including each other
			if (!scanResult.VisitFolder (path))
				return;
			
			if (monitor.LogLevel > 1 && !scanResult.LocateAssembliesOnly)
				monitor.Log ("Checking: " + path);
			
			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 (!Directory.Exists (path))
					scanResult.RegenerateRelationData = true;
			} else {
				if (folderInfo == null && !Directory.Exists (path))
					return;
			}
			
			// if domain is null it means that a new domain has to be created.
			
			bool sharedFolder = domain == AddinDatabase.GlobalDomain;
			
			if (folderInfo == null)
				folderInfo = new AddinScanFolderInfo (path);
			
			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;
					scanResult.RegenerateRelationData = true;
				}
			}
			else if (!folderInfo.SharedFolder && sharedFolder) {
				scanResult.RegenerateRelationData = true;
			}
			
			folderInfo.SharedFolder = sharedFolder;
			
			if (Directory.Exists (path))
			{
				string[] files = Directory.GetFiles (path);
				
				// First of all, look for .addin files. Addin files must be processed before
				// assemblies, because they may add files to the ignore list (i.e., assemblies
				// included in .addin files won't be scanned twice).
				foreach (string file in files) {
					if (file.EndsWith (".addin.xml") || file.EndsWith (".addin")) {
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
					}
				}
				
				foreach (string file in files) {
					switch (Path.GetExtension (file)) {
					case ".dll":
					case ".exe":
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
						scanResult.AddAssemblyLocation (file);
						break;
					case ".addins":
						ScanAddinsFile (monitor, file, domain, scanResult);
						break;
					}
				}
			}
			else if (!scanResult.LocateAssembliesOnly) {
				// 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);
			}
			
			if (scanResult.LocateAssembliesOnly)
				return;
			
			// Look for deleted add-ins.
			
			UpdateDeletedAddins (monitor, folderInfo, scanResult);
		}
Example #6
0
        public void ScanFolder(IProgressStatus monitor, string path, string domain, AddinScanResult scanResult)
        {
            path = Util.GetFullPath(path);

            // Avoid folders including each other
            if (!scanResult.VisitFolder(path))
            {
                return;
            }

            if (monitor.LogLevel > 1 && !scanResult.LocateAssembliesOnly)
            {
                monitor.Log("Checking: " + path);
            }

            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 (!Directory.Exists(path))
                {
                    scanResult.RegenerateRelationData = true;
                }
            }
            else
            {
                if (folderInfo == null && !Directory.Exists(path))
                {
                    return;
                }
            }

            // if domain is null it means that a new domain has to be created.

            bool sharedFolder = domain == AddinDatabase.GlobalDomain;

            if (folderInfo == null)
            {
                folderInfo = new AddinScanFolderInfo(path);
            }

            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;
                    scanResult.RegenerateRelationData = true;
                }
            }
            else if (!folderInfo.SharedFolder && sharedFolder)
            {
                scanResult.RegenerateRelationData = true;
            }

            folderInfo.SharedFolder = sharedFolder;

            if (Directory.Exists(path))
            {
                string[] files = Directory.GetFiles(path);

                // First of all, look for .addin files. Addin files must be processed before
                // assemblies, because they may add files to the ignore list (i.e., assemblies
                // included in .addin files won't be scanned twice).
                foreach (string file in files)
                {
                    if (file.EndsWith(".addin.xml") || file.EndsWith(".addin"))
                    {
                        RegisterFileToScan(monitor, file, scanResult, folderInfo);
                    }
                }

                foreach (string file in files)
                {
                    switch (Path.GetExtension(file))
                    {
                    case ".dll":
                    case ".exe":
                        RegisterFileToScan(monitor, file, scanResult, folderInfo);
                        scanResult.AddAssemblyLocation(file);
                        break;

                    case ".addins":
                        ScanAddinsFile(monitor, file, domain, scanResult);
                        break;
                    }
                }
            }
            else if (!scanResult.LocateAssembliesOnly)
            {
                // 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);
            }

            if (scanResult.LocateAssembliesOnly)
            {
                return;
            }

            // Look for deleted add-ins.

            UpdateDeletedAddins(monitor, folderInfo, scanResult);
        }