[haiku-commits] r41092 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 23 Mar 2011 20:13:21 +0100 (CET)

Author: czeidler
Date: 2011-03-23 20:13:21 +0100 (Wed, 23 Mar 2011)
New Revision: 41092
Changeset: https://dev.haiku-os.org/changeset/41092

Modified:
   haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp
Log:
Only delete fully downloaded messages on the server! Clean up a bit.



Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp
===================================================================
--- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp 
2011-03-23 02:02:20 UTC (rev 41091)
+++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp 
2011-03-23 19:13:21 UTC (rev 41092)
@@ -133,6 +133,10 @@
 status_t
 POP3Protocol::SyncMessages()
 {
+       bool leaveOnServer;
+       if (fSettings.FindBool("leave_mail_on_server", &leaveOnServer) != B_OK)
+               leaveOnServer = true;
+
        // create directory if not exist
        create_directory(fDestinationDir, 0777);
 
@@ -211,6 +215,9 @@
                        }
                        NotifyHeaderFetched(ref, &file);
                        NotifyBodyFetched(ref, &file);
+
+                       if (!leaveOnServer)
+                               Delete(toRetrieve);
                } else {
                        int32 dummy;
                        error = mailIO.ReadAt(0, &dummy, 1);
@@ -232,12 +239,6 @@
                // save manifest in case we get disturbed
                fManifest += uid;
                _WriteManifest();
-
-               bool leaveOnServer;
-               if (fSettings.FindBool("leave_mail_on_server", &leaveOnServer) 
== B_OK
-                       && !leaveOnServer) {
-                       Delete(toRetrieve);
-               }
        }
 
        ResetProgress();
@@ -262,7 +263,6 @@
        if (error < B_OK)
                return error;
 
-       
        BFile file(&ref, B_READ_WRITE);
        status_t status = file.InitCheck();
        if (status != B_OK)
@@ -277,14 +277,12 @@
        if (toRetrieve < 0)
                return B_NAME_NOT_FOUND;
 
+       bool leaveOnServer;
+       if (fSettings.FindBool("leave_mail_on_server", &leaveOnServer) != B_OK)
+               leaveOnServer = true;
+
        // TODO: get rid of this BMailMessageIO!
-       // read header
        BMailMessageIO io(this, &file, toRetrieve);
-       int32 dummy;
-       status = io.ReadAt(0, &dummy, 1);
-       if (status < 0)
-               return status;
-
        // read body
        status = io.Seek(0, SEEK_END);
        if (status < 0)
@@ -292,6 +290,9 @@
 
        NotifyBodyFetched(ref, &file);
 
+       if (!leaveOnServer)
+               Delete(toRetrieve);
+
        ReportProgress(0, 1);
        ResetProgress();
 


Other related posts:

  • » [haiku-commits] r41092 - haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3 - clemens . zeidler