[Checkins] SVN: zope.sendmail/trunk/src/zope/sendmail/delivery.py merge of branch adamg-win32linkfix, where the os.link compatiblity issue should be solved
Adam Groszer
agroszer at gmail.com
Tue Nov 4 07:46:09 EST 2008
Log message for revision 92774:
merge of branch adamg-win32linkfix, where the os.link compatiblity issue should be solved
Changed:
U zope.sendmail/trunk/src/zope/sendmail/delivery.py
-=-
Modified: zope.sendmail/trunk/src/zope/sendmail/delivery.py
===================================================================
--- zope.sendmail/trunk/src/zope/sendmail/delivery.py 2008-11-04 12:05:40 UTC (rev 92773)
+++ zope.sendmail/trunk/src/zope/sendmail/delivery.py 2008-11-04 12:46:08 UTC (rev 92774)
@@ -39,6 +39,12 @@
from transaction.interfaces import IDataManager
import transaction
+import sys
+if sys.platform == 'win32':
+ import win32file
+ _os_link = lambda src, dst: win32file.CreateHardLink(dst, src, None)
+else:
+ _os_link = os.link
# The longest time sending a file is expected to take. Longer than this and
# the send attempt will be assumed to have failed. This means that sending
@@ -326,12 +332,17 @@
# creating this hard link will fail if another process is
# also sending this message
try:
- os.link(filename, tmp_filename)
+ #os.link(filename, tmp_filename)
+ _os_link(filename, tmp_filename)
except OSError, e:
- if e.errno == 17: # file exists
+ if e.errno == 17: # file exists, *nix
# it looks like someone else is sending this
# message too; we'll try again later
continue
+ except error, e:
+ if e[0] == 183 and e[1] == 'CreateHardLink':
+ # file exists, win32
+ continue
# read message file and send contents
file = open(filename)
@@ -347,7 +358,8 @@
"Discarding email from %s to %s due to"
" a permanent error: %s",
fromaddr, ", ".join(toaddrs), str(e))
- os.link(filename, rejected_filename)
+ #os.link(filename, rejected_filename)
+ _os_link(filename, rejected_filename)
else:
# Log an error and retry later
raise
More information about the Checkins
mailing list