remove FileBasedMailbox.get(JS), be sure to set the path
[org.ibex.mail.git] / src / org / ibex / mail / FileBasedMailbox.java
index 2ba6549..c965b9a 100644 (file)
@@ -35,23 +35,18 @@ public class FileBasedMailbox extends Mailbox.Default implements MailTree {
     public void         rename(String subdir, MailTree newParent, String newName) { throw new RuntimeException("FIXME not implemented"); }
     public Mailbox      getMailbox() { return this; }
 
-    public JS get(JS key) throws JSExn {
-        return (JS)slash(JSU.toString(key), true);
-    }
-
     // FIXME: should be a File()
     public static synchronized MailTree getFileBasedMailbox(String path, boolean create) {
         if (path.endsWith(".sqlite")) path = path.substring(0, path.length()-".sqlite".length());
+       path = new File(path).getAbsolutePath().toString();
         try {
             MailTree ret = instances.get(path);
             if (ret == null) {
                 Log.error("n", "no match for " + path + " in " + instances.hashCode());
-                if (new File(path+".sqlite").exists())
-                    ret = new SqliteMailbox(path+".sqlite");
-                else {
-                    if (!create && !(new File(path).exists())) return null;
-                    ret = new FileBasedMailbox(new File(path));
-                }
+                if (new File(path+".sqlite").exists()) ret = new SqliteMailbox(path+".sqlite");
+                else if (new File(path).exists()) ret = new FileBasedMailbox(new File(path));
+                else if (create) ret = new SqliteMailbox(path+".sqlite");
+                else return null;
                 instances.put(path, (MailTree)ret);
                 Log.error("n", "filling " + path + " with " + instances.get(path));
             }
@@ -198,6 +193,7 @@ public class FileBasedMailbox extends Mailbox.Default implements MailTree {
             if ((flags & Mailbox.Flag.SEEN) == 0)  f.setLastModified(MAGIC_DATE);
             else if (f.lastModified()==MAGIC_DATE) f.setLastModified(System.currentTimeMillis());
             // FIXME: other flags?
+            // FIXME: definitely need DELETED flag in order to do message moves!
         }
         public Headers head() { return done() ? null : new Headers(new Fountain.File(file())); }
         public Message cur() { return Message.newMessage(new Fountain.File(file())); }