// 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);