Esempio n. 1
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);
        }
Esempio n. 2
0
	// Remapping hack from DumpIndex
	static Uri RemapUri (LuceneQueryingDriver driver, Uri uri)
	{
		// We only need to remap URIs in the file system backend
		if (driver.IndexName != "FileSystemIndex")
			return uri;

		FileAttributesStore fa_store = new FileAttributesStore (new FileAttributesStore_Mixed (Path.Combine (PathFinder.IndexDir, "FileSystemIndex"), driver.Fingerprint));

		string path = uri.LocalPath;

		Beagrep.Daemon.FileAttributes attr = fa_store.Read (path);
		if (attr == null) {
			Console.WriteLine ("No file attribute info for {0}", uri);
			return uri;
		}

		return new Uri ("uid:" + GuidFu.ToShortString (attr.UniqueId) + uri.Fragment);
	}
Esempio n. 3
0
	static ArrayList RemapUris (LuceneQueryingDriver driver, ArrayList uris)
	{
		// We only need to remap URIs in the file system backend
		if (driver.IndexName != "FileSystemIndex")
			return uris;

		FileAttributesStore fa_store = new FileAttributesStore (new FileAttributesStore_Mixed (Path.Combine (PathFinder.IndexDir, "FileSystemIndex"), driver.Fingerprint));

		for (int i = 0; i < uris.Count; i++) {
			Uri uri = (Uri) uris [i];
			string path = uri.LocalPath;

			Beagrep.Daemon.FileAttributes attr = fa_store.Read (path);
			if (attr == null) {
				Console.WriteLine ("No file attribute info for {0}", uri);
				continue;
			}

			Uri internal_uri = new Uri ("uid:" + GuidFu.ToShortString (attr.UniqueId) + uri.Fragment);
			uris [i] = internal_uri;
		}

		return uris;
	}