public bool RebuildIfNeeded(bool shouldRebuildIfNoProfile = false)
        {
            if (IsRebuildInProgress())
            {
                return(false);
            }
            if (shouldRebuildIfNoProfile && _profileCollection.Empty())
            {
                _logger.InfoFormat("Going to start rebuild becuase of no profile");
                DoRebuild();
                return(true);
            }
            var shouldRebuildIfNoActualVersionForAnyFile = _documentIndexProvider.DocumentIndexTypes.Any(type =>
            {
                var versions = type.GetVersions(_pluginContext.AccountName, _documentIndexSetup);
                return(versions.Except(new[] { type.Version }).Any());
            });
            var shouldRebuildIfNoFile = _documentIndexProvider.DocumentIndexTypes.All(type => type.GetVersions(_pluginContext.AccountName, _documentIndexSetup).Empty());

            if (shouldRebuildIfNoActualVersionForAnyFile || shouldRebuildIfNoFile)
            {
                _logger.InfoFormat("Going to start rebuild becuase of {0}", shouldRebuildIfNoActualVersionForAnyFile ? "no actual version of index file" : "no actual versions of index files");
                DoRebuild();
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 public void Run()
 {
     if (_isOnSite && _profileCollection.Empty())
     {
         var c = new BuildSearchIndexesCommand(_bus, _profileCollection, _pluginContext, _pluginMetadata);
         c.Execute(string.Empty);
     }
     _log.Info("Started Search Plugin");
 }