Exemple #1
0
        /////////////////////////////////////////////////////////////////

        static void AddToRequest(Indexable indexable)
        {
            if (indexable == null)
            {
                return;
            }

            // Disable filtering and only index file attributes
            if (arg_disable_filtering)
            {
                indexable.Filtering = IndexableFiltering.Never;
            }

            // Tag the item for easy identification (for say, removal)
            if (arg_tag != null)
            {
                indexable.AddProperty(Property.NewUnsearched("Tag", arg_tag));
            }

            indexable.Source = arg_source;

            pending_request.Add(indexable);
            bool reschedule = false;

            do
            {
                if (Shutdown.ShutdownRequested)
                {
                    break;
                }

                if (!reschedule && pending_request.Count < BATCH_SIZE)
                {
                    break;
                }

                if (reschedule)
                {
                    Logger.Log.Debug("Continuing indexing indexer generated indexables");
                }
                else
                {
                    Logger.Log.Debug("Flushing driver, {0} items in queue", pending_request.Count);
                }

                reschedule = FlushIndexer(driver);

                // Super Lame Hack: gtk-sharp up to 2.10 requires a main loop
                // to dispose of any managed wrappers around GObjects.  Since
                // we don't have one, we'll process all the pending items in
                // a loop here.  This is particularly an issue with maildirs,
                // because we need the loop to clean up after GMime.  Without
                // it, GMime's streams are never completely unref'd, the
                // file descriptors aren't closed, and we run out and crash.
                while (GLib.MainContext.Pending())
                {
                    GLib.MainContext.Iteration();
                }
            } while (reschedule);
        }
Exemple #2
0
        //////////////////////////////////////////////////////////////////////////////////

        protected void AddIndexable(Indexable indexable)
        {
            indexable.Source = QueryDriver.GetQueryable(this).Name;

            lock (request_lock)
                pending_request.Add(indexable);

            // Schedule a final flush every time we add anything.
            // Better safe than sorry.
            ScheduleFinalFlush();
        }
	static void Main (string[] args)
	{
		if (args.Length != 2) {
			Console.WriteLine ("Usage: beagle-master-delete-button index-name uri-to-delete");
			return;
		}

		string index_name = args [0];

		LuceneQueryingDriver driver = new LuceneQueryingDriver (index_name, -1, true);

		Uri uri = new Uri (args [1], false);
		Uri uri_to_delete = RemapUri (driver, uri);

		LuceneIndexingDriver indexer = new LuceneIndexingDriver (index_name, false);

		Indexable indexable = new Indexable (uri_to_delete);
		indexable.Type = IndexableType.Remove;

		IndexerRequest request = new IndexerRequest ();
		request.Add (indexable);

		IndexerReceipt [] receipts = indexer.Flush (request);
		if (receipts == null || receipts.Length == 0) {
			Console.WriteLine ("Uri {0} not found in {1}",
					   uri, index_name);
			return;
		}

		IndexerRemovedReceipt r = receipts [0] as IndexerRemovedReceipt;
		if (r == null || r.NumRemoved == 0) {
			Console.WriteLine ("Uri {0} not found in {1}",
					   uri, index_name);
			return;
		}

		Console.WriteLine ("Uri {0} deleted", uri);
	}