also sprach Julien BLACHE <[EMAIL PROTECTED]> [2007.08.24.1843 +0100]:
> Obvious typo.

Updated patch, which also actually includes the code I was testing
with:

--- /tmp/Maildir.py.orig        2007-08-25 11:22:45.000000000 +0100
+++ /usr/share/python-support/offlineimap/offlineimap/folder/Maildir.py 
2007-08-25 11:29:37.000000000 +0100
@@ -146,7 +146,8 @@
         # Otherwise, save the message in tmp/ and then call savemessageflags()
         # to give it a permanent home.
         tmpdir = os.path.join(self.getfullname(), 'tmp')
-        messagename = None
+        file = fd = None
+        messagename = tmpmessagename = None
         attempts = 0
         while 1:
             if attempts > 15:
@@ -159,19 +160,25 @@
                            socket.gethostname(),
                            uid,
                            md5.new(self.getvisiblename()).hexdigest())
-            if os.path.exists(os.path.join(tmpdir, messagename)):
-                time.sleep(2)
-                attempts += 1
-            else:
+            tmpmessagename = messagename.split(',')[0]
+            try:
+                fd = os.open(os.path.join(tmpdir, tmpmessagename),
+                        os.O_WRONLY + os.O_CREAT + os.O_EXCL)
+                file = os.fdopen(fd, 'w')
+                ui.debug('maildir', 'savemessage: using temporary name %s' % 
tmpmessagename)
                 break
-        tmpmessagename = messagename.split(',')[0]
-        ui.debug('maildir', 'savemessage: using temporary name %s' % 
tmpmessagename)
-        file = open(os.path.join(tmpdir, tmpmessagename), "wt")
+            except OSError, e:
+                if e.errno == 17:
+                    time.sleep(2)
+                    attempts += 1
+                    continue
+                raise
+
         file.write(content)
 
         # Make sure the data hits the disk
         file.flush()
-        os.fsync(file.fileno())
+        os.fsync(fd)
 
         file.close()
         if rtime != None:

-- 
 .''`.   martin f. krafft <[EMAIL PROTECTED]>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
 
* Overfiend came out of the womb complaining.
                                                    -- #debian-devel

Attachment: digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)

Reply via email to