james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1132687 - in /james/mailbox/trunk: maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java store/src/main/java/org/apache/james/mailbox/store/search/lucene/LuceneMessageSearchIndex.java
Date Mon, 06 Jun 2011 15:59:45 GMT
Author: norman
Date: Mon Jun  6 15:59:45 2011
New Revision: 1132687

URL: http://svn.apache.org/viewvc?rev=1132687&view=rev
Log:
Make sure flag updates will get reflected correctly in the MessageSearchIndex. See MAILBOX-10

Modified:
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/lucene/LuceneMessageSearchIndex.java

Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java?rev=1132687&r1=1132686&r2=1132687&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
(original)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
Mon Jun  6 15:59:45 2011
@@ -477,7 +477,7 @@ public class MaildirMessageMapper extend
      * (non-Javadoc)
      * @see org.apache.james.mailbox.store.mail.MessageMapper#updateFlags(org.apache.james.mailbox.store.mail.model.Mailbox,
javax.mail.Flags, boolean, boolean, org.apache.james.mailbox.MessageRange)
      */
-    public Iterator<UpdatedFlags> updateFlags(final Mailbox<Integer> mailbox,
final Flags flags, final boolean value, final boolean replace, MessageRange set) throws MailboxException
{
+    public Iterator<UpdatedFlags> updateFlags(final Mailbox<Integer> mailbox,
final Flags flags, final boolean value, final boolean replace, final MessageRange set) throws
MailboxException {
         final List<UpdatedFlags> updatedFlags = new ArrayList<UpdatedFlags>();
         final MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
 
@@ -522,6 +522,11 @@ public class MaildirMessageMapper extend
                         long modSeq;
                         // if the flags don't have change we should not try to move the file
                         if (newMessageFile.equals(messageFile) == false) {
+
+                            if (replace == false && index != null) {
+                                index.update(mailboxSession, mailbox, MessageRange.one(member.getUid()),
newFlags);
+                            }
+                            
                             FileUtils.moveFile(messageFile, newMessageFile );
                             modSeq = newMessageFile.lastModified();
 
@@ -539,6 +544,12 @@ public class MaildirMessageMapper extend
                     }
 
                 }
+                
+                // as it was a replace operation we can just use the given message for update
the index
+                if (replace && index != null) {
+                    index.update(mailboxSession, mailbox, set, flags);
+                }
+                
             }
         });
         

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/lucene/LuceneMessageSearchIndex.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/lucene/LuceneMessageSearchIndex.java?rev=1132687&r1=1132686&r2=1132687&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/lucene/LuceneMessageSearchIndex.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/lucene/LuceneMessageSearchIndex.java
Mon Jun  6 15:59:45 2011
@@ -946,9 +946,13 @@ public class LuceneMessageSearchIndex<Id
             ScoreDoc[] sDocs = docs.scoreDocs;
             for (int i = 0; i < sDocs.length; i++) {
                 Document doc = searcher.doc(sDocs[i].doc);
-                doc.removeFields(FLAGS_FIELD);
-                indexFlags(doc, f);
-                writer.updateDocument(new Term(ID_FIELD, doc.get(ID_FIELD)), doc);
+                
+                if (doc.getField(FLAGS_FIELD) == null) {
+                    doc.removeFields(FLAGS_FIELD);
+                    indexFlags(doc, f);
+                    writer.updateDocument(new Term(ID_FIELD, doc.get(ID_FIELD)), doc);
+            
+                }
             }
         } catch (IOException e) {
             throw new MailboxException("Unable to add messages in index", e);



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message