forked from I2P_Developers/i2p.i2p
SusiMail: Remove disk null checks, always non-null
This commit is contained in:
@@ -89,7 +89,6 @@ class MailCache {
|
|||||||
this.mailbox = mailbox;
|
this.mailbox = mailbox;
|
||||||
mails = new Hashtable<String, Mail>();
|
mails = new Hashtable<String, Mail>();
|
||||||
disk = new PersistentMailCache(ctx, host, port, user, pass, folderName);
|
disk = new PersistentMailCache(ctx, host, port, user, pass, folderName);
|
||||||
// TODO Drafts, Sent, Trash
|
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
Folder<String> folder = new Folder<String>();
|
Folder<String> folder = new Folder<String>();
|
||||||
// setElements() sorts, so configure the sorting first
|
// setElements() sorts, so configure the sorting first
|
||||||
@@ -373,7 +372,7 @@ class MailCache {
|
|||||||
Buffer rb = mailbox.getBody(uidl, new FileBuffer(file));
|
Buffer rb = mailbox.getBody(uidl, new FileBuffer(file));
|
||||||
if (rb != null) {
|
if (rb != null) {
|
||||||
mail.setBody(rb);
|
mail.setBody(rb);
|
||||||
if (disk != null && disk.saveMail(mail) &&
|
if (disk.saveMail(mail) &&
|
||||||
!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
||||||
mailbox.queueForDeletion(mail.uidl);
|
mailbox.queueForDeletion(mail.uidl);
|
||||||
}
|
}
|
||||||
@@ -439,17 +438,15 @@ class MailCache {
|
|||||||
headerOnly = false;
|
headerOnly = false;
|
||||||
if( headerOnly ) {
|
if( headerOnly ) {
|
||||||
if(!mail.hasHeader()) {
|
if(!mail.hasHeader()) {
|
||||||
if (disk != null) {
|
if (disk.getMail(mail, true)) {
|
||||||
if (disk.getMail(mail, true)) {
|
if (_log.shouldDebug()) _log.debug("Loaded header from disk cache: " + uidl);
|
||||||
if (_log.shouldDebug()) _log.debug("Loaded header from disk cache: " + uidl);
|
// note that disk loaded the full body if it had it
|
||||||
// note that disk loaded the full body if it had it
|
if (mail.hasBody() &&
|
||||||
if (mail.hasBody() &&
|
!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
||||||
!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
// we already have it, send delete
|
||||||
// we already have it, send delete
|
mailbox.queueForDeletion(mail.uidl);
|
||||||
mailbox.queueForDeletion(mail.uidl);
|
|
||||||
}
|
|
||||||
continue; // found on disk, woo
|
|
||||||
}
|
}
|
||||||
|
continue; // found on disk, woo
|
||||||
}
|
}
|
||||||
POP3Request pr = new POP3Request(mail, true, new MemoryBuffer(1024));
|
POP3Request pr = new POP3Request(mail, true, new MemoryBuffer(1024));
|
||||||
fetches.add(pr);
|
fetches.add(pr);
|
||||||
@@ -462,16 +459,14 @@ class MailCache {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!mail.hasBody()) {
|
if(!mail.hasBody()) {
|
||||||
if (disk != null) {
|
if (disk.getMail(mail, false)) {
|
||||||
if (disk.getMail(mail, false)) {
|
if (_log.shouldDebug()) _log.debug("Loaded body from disk cache: " + uidl);
|
||||||
if (_log.shouldDebug()) _log.debug("Loaded body from disk cache: " + uidl);
|
// note that disk loaded the full body if it had it
|
||||||
// note that disk loaded the full body if it had it
|
if (!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
||||||
if (!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
// we already have it, send delete
|
||||||
// we already have it, send delete
|
mailbox.queueForDeletion(mail.uidl);
|
||||||
mailbox.queueForDeletion(mail.uidl);
|
|
||||||
}
|
|
||||||
continue; // found on disk, woo
|
|
||||||
}
|
}
|
||||||
|
continue; // found on disk, woo
|
||||||
}
|
}
|
||||||
File file = new File(_context.getTempDir(), "susimail-new-" + _context.random().nextLong());
|
File file = new File(_context.getTempDir(), "susimail-new-" + _context.random().nextLong());
|
||||||
POP3Request pr = new POP3Request(mail, false, new FileBuffer(file));
|
POP3Request pr = new POP3Request(mail, false, new FileBuffer(file));
|
||||||
@@ -504,11 +499,9 @@ class MailCache {
|
|||||||
mail.setBody(pr.getBuffer());
|
mail.setBody(pr.getBuffer());
|
||||||
}
|
}
|
||||||
rv = true;
|
rv = true;
|
||||||
if (disk != null) {
|
if (disk.saveMail(mail) && mail.hasBody() &&
|
||||||
if (disk.saveMail(mail) && mail.hasBody() &&
|
!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
||||||
!Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) {
|
mailbox.queueForDeletion(mail.uidl);
|
||||||
mailbox.queueForDeletion(mail.uidl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -539,8 +532,7 @@ class MailCache {
|
|||||||
public void delete(Collection<String> uidls) {
|
public void delete(Collection<String> uidls) {
|
||||||
List<String> toDelete = new ArrayList<String>(uidls.size());
|
List<String> toDelete = new ArrayList<String>(uidls.size());
|
||||||
for (String uidl : uidls) {
|
for (String uidl : uidls) {
|
||||||
if (disk != null)
|
disk.deleteMail(uidl);
|
||||||
disk.deleteMail(uidl);
|
|
||||||
synchronized(mails) {
|
synchronized(mails) {
|
||||||
Mail mail = mails.get(uidl);
|
Mail mail = mails.get(uidl);
|
||||||
if (mail == null)
|
if (mail == null)
|
||||||
|
Reference in New Issue
Block a user