private Indexable OperaRowToIndexable(OperaHistory.Row row) { // It's unsafe to index secure content since it may contain sensitive data if (row.Address.Scheme == Uri.UriSchemeHttps) { return(null); } Indexable indexable = new Indexable(row.Address); indexable.HitType = "WebHistory"; indexable.MimeType = row.MimeType; indexable.Timestamp = row.LastVisited; indexable.AddProperty(Beagle.Property.New("fixme:host", row.Address.Host)); indexable.AddProperty(Beagle.Property.NewUnsearched("fixme:size", row.Length)); // hint for the filter about the charset indexable.AddProperty(Property.NewUnsearched(StringFu.UnindexedNamespace + "charset", row.Encoding.ToString())); if (row.Compression == "gzip") { indexable.SetBinaryStream(new GZipInputStream(File.OpenRead(Path.Combine(cache_dir, row.LocalFileName)))); } else { indexable.ContentUri = new Uri(Path.Combine(cache_dir, row.LocalFileName)); } indexer.AttributeStore.AttachLastWriteTime(Path.Combine(cache_dir, row.LocalFileName), DateTime.UtcNow); return(indexable); }
public Indexable GetNextIndexable() { OperaHistory.Row row = (OperaHistory.Row)history_enumerator.Current; try { return(OperaRowToIndexable(row)); } catch (Exception ex) { Log.Error(ex, "Unable to index {0} ({1})", row.Address, row.LocalFileName); return(null); } }
public bool Allowed(OperaHistory.Row row) { foreach (string mime in indexed_mimetypes) { if (row.MimeType == mime) { return(true); } } return(false); }
public bool HasNextIndexable() { if (history_enumerator == null) { return(false); } while (history_enumerator.MoveNext()) { OperaHistory.Row row = (OperaHistory.Row)history_enumerator.Current; if (Allowed(row) && !IsUpToDate(row)) { return(true); } } history_enumerator = null; history = null; // Help the GC here return(false); }
public bool IsUpToDate(OperaHistory.Row row) { return(indexer.AttributeStore.IsUpToDate(Path.Combine(cache_dir, row.LocalFileName))); }