// Update System Managed Import Paths
        public static void UpdateImportPaths()
        {
            // remove obsolete or invalid import paths
            foreach (DBImportPath currPath in DBImportPath.GetAll())
            {
                if (currPath.Directory == null)
                {
                    currPath.Delete();
                }

                if (currPath.InternallyManaged && currPath.GetDriveType() == DriveType.NoRootDirectory)
                {
                    currPath.Delete();
                    logger.Info("Removed system managed import path: {0} (drive does not exist)", currPath.FullPath);
                }

                // Automatically remove import paths that were marked as replaced and don't have any related media (left)
                if (currPath.Replaced)
                {
                    // get related local media (we append % so we get all paths starting with the import path)
                    List <DBLocalMedia> attachedLocalMedia = DBLocalMedia.GetAll(currPath.FullPath + "%");
                    if (attachedLocalMedia.Count == 0)
                    {
                        currPath.Delete();
                        logger.Info("Removed import path: {0} (was marked as replaced and doesn't have any related files)", currPath.FullPath);
                    }
                }
            }

            float count = 0;
            float total = DriveInfo.GetDrives().Length;

            bool   daemonEnabled = mvCentralCore.MediaPortalSettings.GetValueAsBool("daemon", "enabled", false);
            string virtualDrive  = mvCentralCore.MediaPortalSettings.GetValueAsString("daemon", "drive", "?:");

            // Get all drives
            foreach (DriveInfo drive in DriveInfo.GetDrives())
            {
                if (MaintenanceProgress != null)
                {
                    MaintenanceProgress("", (int)(count * 100 / total));
                }
                count++;

                // Add the import path if it does not exist and
                // is not marked virtual by MediaPortal.
                DBImportPath importPath = DBImportPath.Get(drive.Name);
                bool         isVirtual  = drive.Name.StartsWith(virtualDrive, StringComparison.OrdinalIgnoreCase) && daemonEnabled;
                bool         isCDRom    = (drive.DriveType == DriveType.CDRom);

                if (importPath.ID != null)
                {
                    // Remove an system managed path if for any reason it's not of type CDRom
                    if (!isCDRom && importPath.InternallyManaged)
                    {
                        importPath.Delete();
                        logger.Info("Removed system managed import path: {0} (drive type has changed)", importPath.FullPath);
                        continue;
                    }

                    // Remove an existing path if it's defined as the virtual drive
                    if (isVirtual)
                    {
                        importPath.Delete();
                        logger.Info("Removed import path: {0} (drive is marked as virtual)", importPath.FullPath);
                        continue;
                    }

                    // Update an existing import path to a system managed import path
                    // if the drive type is CDRom but the system flag isn't set
                    if (isCDRom && !importPath.InternallyManaged)
                    {
                        importPath.InternallyManaged = true;
                        importPath.Commit();
                        logger.Info("{0} was updated to a system managed import path.", importPath.FullPath);
                    }
                }
                else
                {
                    if (isCDRom && !isVirtual)
                    {
                        importPath.InternallyManaged = true;
                        importPath.Commit();
                        logger.Info("Added system managed import path: {0}", importPath.FullPath);
                    }
                }
            }

            if (MaintenanceProgress != null)
            {
                MaintenanceProgress("", 100);
            }
        }