public void Dispose()
        {
            LogManager.GetCurrentClassLogger().Info("Stopping Lucene indexing services.");

            if (PackageFileSystemWatcher != null)
            {
                PackageFileSystemWatcher.Dispose();
            }

            PackageIndexer.Dispose();
            Provider.Dispose();
            LuceneDirectory.Dispose();
        }
예제 #2
0
        public void Initialize()
        {
            var packagePathResolver = CreatePackagePathResolver();
            var fileSystem          = new PhysicalFileSystem(PackagePath)
            {
                Logger = new NuGetCommonLoggingAdapter()
            };
            var hashProvider = new CryptoHashProvider(PackageHashAlgorithm);

            CreateDirectories();
            InitializeLucene();

            PackageIndexer = new PackageIndexer
            {
                FileSystem = fileSystem,
                Provider   = Provider,
                Writer     = Provider.IndexWriter
            };

            var repository = new LucenePackageRepository(packagePathResolver, fileSystem)
            {
                HashProvider         = hashProvider,
                HashAlgorithmName    = PackageHashAlgorithm,
                DisablePackageHash   = DisablePackageHash,
                IgnorePackageFiles   = IgnorePackageFiles,
                PathResolver         = packagePathResolver,
                Indexer              = PackageIndexer,
                LuceneDataProvider   = Provider,
                LucenePackages       = Provider.AsQueryable(() => new LucenePackage(fileSystem)),
                LucenePackageSource  = string.Format("{0} (with Lucene.Net index in {1})", PackagePath, LuceneIndexPath),
                PackageOverwriteMode = PackageOverwriteMode
            };

            // TODO: circular reference
            PackageIndexer.PackageRepository = repository;

            PackageIndexer.Initialize();
            repository.Initialize();

            Repository = repository;

            InitializeFileSystemWatcher(fileSystem, repository);
        }
        public void Initialize()
        {
            var packagePathResolver = CreatePackagePathResolver();
            var fileSystem = new PhysicalFileSystem(PackagePath);
            var hashProvider = new CryptoHashProvider(PackageHashAlgorithm);

            CreateDirectories();
            InitializeLucene();
            
            PackageIndexer = new PackageIndexer
                {
                    FileSystem = fileSystem,
                    Provider = Provider,
                    Writer = Provider.IndexWriter
                };

            var repository = new LucenePackageRepository(packagePathResolver, fileSystem)
                {
                    HashProvider = hashProvider,
                    HashAlgorithm = PackageHashAlgorithm,
                    PathResolver = packagePathResolver,
                    Indexer = PackageIndexer,
                    LuceneDataProvider = Provider,
                    LucenePackages = Provider.AsQueryable(() => new LucenePackage(fileSystem)),
                    LucenePackageSource = string.Format("{0} (with Lucene.Net index in {1})", PackagePath, LuceneIndexPath)
                };

            // TODO: circular reference
            PackageIndexer.PackageRepository = repository;

            PackageIndexer.Initialize();
            repository.Initialize();

            Repository = repository;

            InitializeFileSystemWatcher(fileSystem, repository);
        }