Ejemplo 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);
        }
Ejemplo 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);
        }