Undo 'Fix Maildir race' patch

This was causing OfflineIMAP to hang
This commit is contained in:
John Goerzen 2007-10-19 20:29:34 +01:00
parent 393d095ac1
commit 24cdba3221

View File

@ -158,8 +158,7 @@ class MaildirFolder(BaseFolder):
# Otherwise, save the message in tmp/ and then call savemessageflags() # Otherwise, save the message in tmp/ and then call savemessageflags()
# to give it a permanent home. # to give it a permanent home.
tmpdir = os.path.join(self.getfullname(), 'tmp') tmpdir = os.path.join(self.getfullname(), 'tmp')
file = fd = None messagename = None
messagename = tmpmessaename = None
attempts = 0 attempts = 0
while 1: while 1:
if attempts > 15: if attempts > 15:
@ -172,24 +171,19 @@ class MaildirFolder(BaseFolder):
socket.gethostname(), socket.gethostname(),
uid, uid,
md5.new(self.getvisiblename()).hexdigest()) md5.new(self.getvisiblename()).hexdigest())
tmpmessagename = messagename.split(',')[0] if os.path.exists(os.path.join(tmpdir, messagename)):
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)
except OSError, e:
if e.errno == 17:
time.sleep(2) time.sleep(2)
attempts += 1 attempts += 1
continue else:
raise break
tmpmessagename = messagename.split(',')[0]
ui.debug('maildir', 'savemessage: using temporary name %s' % tmpmessagename)
file = open(os.path.join(tmpdir, tmpmessagename), "wt")
file.write(content) file.write(content)
# Make sure the data hits the disk # Make sure the data hits the disk
file.flush() file.flush()
os.fsync(fd) os.fsync(file.fileno())
file.close() file.close()
if rtime != None: if rtime != None: