+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
package org.ibex.mail.target;
import org.prevayler.*;
import org.ibex.mail.*;
public void init(final Prevayler prevayler) throws IOException {
dir.mkdirs();
+ long time = System.currentTimeMillis();
Log.info(this, "initializing maildir " + dir.getParent());
// Drop entries whose files have vanished
}
// Take a snapshot for posterity
- Log.info(this, " done initializing maildir " + dir.getParent());
+ if (System.currentTimeMillis() - time > 1000 * 5)
+ Log.info(this, " done initializing maildir " + dir.getParent());
new Thread() { public void run() {
try { prevayler.takeSnapshot(); } catch (Exception e) { Log.error(this, e); } } }.start();
}
public static Transaction create(File f) throws IOException {
final boolean seen = f.lastModified() == MAGIC_DATE;
- Log.error(Entry.class, "create with seen = " + seen);
final String name = f.getName();
final byte[] header = new MIME.Headers(new Stream(new FileInputStream(f)), true).toString().getBytes();
return new Transaction() {
public int uidNext() { return cache.uidNext(); }
public synchronized void add(Message message, int flags) {
- Log.info(path, message.summary());
try {
String name, fullname; File target, f;
for(int i = cache.uidNext(); ; i++) {
}
FileOutputStream fo = new FileOutputStream(f);
Stream stream = new Stream(fo);
- if (message.envelope != null) {
- stream.println("X-org.ibex.mail.headers.envelope.From: " + message.envelope.from);
- stream.println("X-org.ibex.mail.headers.envelope.To: " + message.envelope.to);
- }
message.dump(stream);
fo.close();
f.renameTo(new File(fullname));
if ((flags & Mailbox.Flag.SEEN) == Mailbox.Flag.SEEN) f.setLastModified(MAGIC_DATE);
prevayler.execute(Cache.Entry.create(f));
} catch (IOException e) { throw new MailException.IOException(e); }
+ Log.info(this, path + " <= " + message.summary());
}
private class Iterator extends Mailbox.Default.Iterator {
public boolean done() { return cur >= cache.size(); }
public boolean next() { cur++; return !done(); }
public boolean seen() { return done() ? false : entry().seen(); }
+ public boolean recent() { return false; }
public int num() { return cur+1; } // EUDORA insists that message numbers start at 1, not 0
public int uid() { return done() ? -1 : entry().uid; }
public void delete() { prevayler.execute(entry().delete(file())); }