Class PersistentMailCache


  • class PersistentMailCache
    extends Object
    Manage the on-disk cache. This is a custom format with subdirectories, gzipped files, and the encoded UIDL in the file name. We store either the headers or the full message. No, it is not Maildir format but we could add Maildir-style status suffixes (e.g. ":2.SR") later. Exporting to a Maildir format would be just ungzipping each file to a flat directory. This class should only be accessed from MailCache. TODO cached server caps and config.
    Since:
    0.9.14
    • Constructor Detail

      • PersistentMailCache

        public PersistentMailCache​(I2PAppContext ctx,
                                   String host,
                                   int port,
                                   String user,
                                   String pass,
                                   String folder)
                            throws IOException
        Use the params to generate a unique directory name. Does NOT load the mails in. Caller MUST call getMails().
        Parameters:
        pass - ignored
        folder - e.g. DIR_FOLDER
        Throws:
        IOException
    • Method Detail

      • getMails

        public Collection<Mail> getMails()
        Fetch all mails from disk.
        Returns:
        a new collection
      • getMail

        public boolean getMail​(Mail mail,
                               boolean headerOnly)
        Fetch any needed data from disk.
        Returns:
        success
      • saveMail

        public boolean saveMail​(Mail mail)
        Save data to disk.
        Returns:
        success
      • deleteMail

        public void deleteMail​(Mail mail)
        Delete data from disk.
      • deleteMail

        public void deleteMail​(String uidl)
        Delete data from disk.
      • getHeaderFile

        public File getHeaderFile​(String uidl)
      • getFullFile

        public File getFullFile​(String uidl)
      • getFullBuffer

        public GzipFileBuffer getFullBuffer​(String uidl)
        For reading or writing a new full mail (NOT headers only). For writing, caller MUST call writeComplete() on rv. Does not necessarily exist.
        Since:
        0.9.35
      • getAttachmentDir

        public File getAttachmentDir()
        Returns:
        non-null only for Drafts
        Since:
        0.9.35