// acquire lock
File lockfile = new File(this.path.getAbsolutePath() + slash + ".lock");
lock = new RandomAccessFile(lockfile, "rw").getChannel().tryLock();
- if (lock == null) throw new IOException("unable to lock FileBasedMailbox");
+ /*
+ if (lock == null) {
+ Log.warn(this, "warning: blocking waiting for a lock on " + path);
+ lock = new RandomAccessFile(lockfile, "rw").getChannel().lock();
+ if (lock == null) throw new IOException("unable to lock FileBasedMailbox: " + path);
+ }
+ lockfile.deleteOnExit();
+ */
+
uidValidity = (int)(lockfile.lastModified() & 0xffffffff);
uidNext = 0;
String[] files = path.list();
};
public Mailbox.Iterator iterator() { return new Iterator(); }
- public synchronized void add(Message message) { add(message, Mailbox.Flag.RECENT); }
public String[] children() {
Vec vec = new Vec();
String[] list = sort(path.list());
public int uidValidity() { return uidValidity; }
public int uidNext() { return uidNext; }
- public synchronized void add(Message message, int flags) {
+ public synchronized void insert(Message message, int flags) {
try {
String name, fullname; File target, f;
for(int i = uidNext; ; i++) {
target = new File(fullname);
f = new File(target.getCanonicalPath() + "-");
if (!f.exists() && !target.exists()) break;
- Log.error(this, "aieeee!!!! target of add() already exists: " + target.getAbsolutePath());
+ Log.error(this, "aieeee!!!! target of insert() already exists: " + target.getAbsolutePath());
}
Stream stream = new Stream(new FileOutputStream(f));
message.getStream().transcribe(stream);
public boolean next() { cur++; return !done(); }
public boolean seen() { return false; }
public boolean recent() { return false; }
- public int num() { return cur+1; } // EUDORA insists that message numbers start at 1, not 0
+ public int nntpNumber() { return cur+1; } // FIXME: lame
+ public int imapNumber() { return cur+1; } // EUDORA insists that message numbers start at 1, not 0
public int uid() { return done() ? -1 : Integer.parseInt(files[cur].substring(0, files[cur].length()-1)); }
public void delete() { File f = file(); if (f != null && f.exists()) f.delete(); }
public void seen(boolean seen) { }
s[0] = (m.from==null?"":m.from.toString(true));
s[1] = m.subject;
s[2] = (m.date + "").trim().replaceAll(" "," ");
- s[3] = it.num() + "";
+ s[3] = it.imapNumber() + "";
msgs.addElement(s);
}
String[][] messages;
int target = Integer.parseInt(request.getParameter("msgnum"));
Mailbox.Iterator it = mbox.iterator();
while(it.next())
- if (it.num() == target)
+ if (it.imapNumber() == target)
break;
if (it.cur() != null) {
pw.println(" <table width=100% border=0 cellspacing=0 style='border: 1px black solid; background-color:#F0F0E0;'>");