Beispiel #1
0
 private void IndexFile(ref int newCount, ref int updatedCount, ref int unchangedCount, CdrReader cdrReader, FileInfo file)
 {
     string path = file.FullName;
     string hash = CalculateHash(path);
     Entry entry = LuceneStore.Current.Find(path);
     if (entry == null)
     {
         this.log("+");
         newCount++;
         entry = new Entry
         {
             Path = file.FullName.ToLower(),
             Name = file.Name,
             Hash = hash,
             ModifiedOn = file.LastWriteTime,
         };
         ReadText(path, entry, cdrReader);
         LuceneStore.Current.Insert(entry);
     }
     else if (entry.Hash != hash)
     {
         this.log("*");
         updatedCount++;
         entry.Hash = hash;
         ReadText(path, entry, cdrReader);
         LuceneStore.Current.Update(entry);
     }
     else
     {
         this.log(".");
         unchangedCount++;
     }
     this.onFileIndexed();
 }
Beispiel #2
0
 public void Update(Entry entry)
 {
     this.writer.UpdateDocument(FindTerm(entry.Path), entry.ToDocument());
     this.writer.Flush(triggerMerge: false, flushDocStores: true, flushDeletes: true);
 }
Beispiel #3
0
 private void ReadText(string path, Entry entry, CdrReader cdrReader)
 {
     entry.Text = cdrReader.ReadText(path);
     entry.CalculateAll();
 }
Beispiel #4
0
 public void Insert(Entry entry)
 {
     this.writer.AddDocument(entry.ToDocument());
     this.writer.Flush(triggerMerge: false, flushDocStores: true, flushDeletes: true);
 }