Exemplo n.º 1
0
                static Indexable FileToIndexable (FileInfo file)
                {
                        if (!file.Exists)
                                return null;

                        if (fa_store.IsUpToDateAndFiltered (PathInIndex (file.FullName),
                                                            FileSystem.GetLastWriteTimeUtc (file.FullName)))
                                return null;

                        // Create the indexable and add the standard properties we
                        // use in the FileSystemQueryable.
                        Uri uri = PathToUri (file.FullName);
                        Indexable indexable = new Indexable (uri);
                        indexable.Timestamp = file.LastWriteTimeUtc;
                        indexable.FlushBufferCache = true;
                        indexable.AddProperty (Property.NewUnsearched ("fixme:filesize", file.Length));
                        FSQ.AddStandardPropertiesToIndexable (indexable, file.Name, Guid.Empty, false);

                        // Store directory name in the index
                        string dirname = file.DirectoryName;
                        indexable.AddProperty (Property.NewUnsearched (Property.ParentDirUriPropKey, PathToUri (dirname)));

                        return indexable;
                }
Exemplo n.º 2
0
                static Indexable DirectoryToIndexable (DirectoryInfo dir, Queue modified_directories)
                {
                        if (!dir.Exists)
                                return null;

                        // Check if the directory information is stored in attributes store
                        // And if the mtime of the directory is same as that in the attributes store
                        FileAttributes attr = fa_store.Read (PathInIndex (dir.FullName));

                        // If the directory exists in the fa store, then it is already indexed.
                        if (attr != null) {
                                // If we don't care about deleted content then we are fine.
                                // If the attributes are up-to-date, then we are fine too.
                                if (! arg_delete || FileAttributesStore.IsUpToDate (attr, FileSystem.GetLastWriteTimeUtc (dir.FullName)))
                                        return null;

                                // But the last write time needs to be uptodate to support enable-deletion,
                                // so we actually index the directories, even if --disable-directories
                                // is set.
                                modified_directories.Enqueue (dir);
                        }

                        // Create the indexable and add the standard properties we
                        // use in the FileSystemQueryable.
                        Uri uri = PathToUri (dir.FullName);
                        Indexable indexable = new Indexable (uri);
                        indexable.MimeType = "inode/directory";
                        indexable.NoContent = true;
                        indexable.Timestamp = dir.LastWriteTimeUtc;

                        // Store the directory information in the index anyway, but if --disable-directories
                        // was passed, then do not store the names and other standard properties
                        // used during searching
                        if (! arg_disable_directories)
                                FSQ.AddStandardPropertiesToIndexable (indexable, dir.Name, Guid.Empty, false);

                        // Add directory name property
                        string dirname = dir.Parent.FullName;
                        indexable.AddProperty (Property.NewUnsearched (Property.ParentDirUriPropKey, PathToUri (dirname)));

                        indexable.AddProperty (Property.NewBool (Property.IsDirectoryPropKey, true));

                        return indexable;
                }
Exemplo n.º 3
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);
                }