commit
87f9507cc9
@ -302,7 +302,15 @@ class BaseFolder:
|
|||||||
|
|
||||||
with open(uidfilename + ".tmp", "wt") as uidfile:
|
with open(uidfilename + ".tmp", "wt") as uidfile:
|
||||||
uidfile.write("%d\n" % newval)
|
uidfile.write("%d\n" % newval)
|
||||||
|
|
||||||
|
# This is weird, os.rename on Windows raises an exception,
|
||||||
|
# But not in Linux. In linux the file is overwritten.
|
||||||
|
try:
|
||||||
os.rename(uidfilename + ".tmp", uidfilename)
|
os.rename(uidfilename + ".tmp", uidfilename)
|
||||||
|
except WindowsError:
|
||||||
|
os.remove(uidfilename)
|
||||||
|
os.rename(uidfilename + ".tmp", uidfilename)
|
||||||
|
|
||||||
self._base_saved_uidvalidity = newval
|
self._base_saved_uidvalidity = newval
|
||||||
|
|
||||||
def get_uidvalidity(self):
|
def get_uidvalidity(self):
|
||||||
|
@ -183,7 +183,7 @@ class GmailMaildirFolder(MaildirFolder):
|
|||||||
os.rename(tmppath, filepath)
|
os.rename(tmppath, filepath)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise OfflineImapError("Can't rename file '%s' to '%s': %s" %
|
raise OfflineImapError("Can't rename file '%s' to '%s': %s" %
|
||||||
(tmppath, filepath, e[1]),
|
(tmppath, filepath, e.errno),
|
||||||
OfflineImapError.ERROR.FOLDER,
|
OfflineImapError.ERROR.FOLDER,
|
||||||
exc_info()[2])
|
exc_info()[2])
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ class MaildirFolder(BaseFolder):
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise OfflineImapError(
|
raise OfflineImapError(
|
||||||
"Can't rename file '%s' to '%s': %s" %
|
"Can't rename file '%s' to '%s': %s" %
|
||||||
(oldfilename, newfilename, e[1]),
|
(oldfilename, newfilename, e.errno),
|
||||||
OfflineImapError.ERROR.FOLDER,
|
OfflineImapError.ERROR.FOLDER,
|
||||||
exc_info()[2])
|
exc_info()[2])
|
||||||
|
|
||||||
@ -556,7 +556,7 @@ class MaildirFolder(BaseFolder):
|
|||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise OfflineImapError(
|
raise OfflineImapError(
|
||||||
"Can't rename file '%s' to '%s': %s" %
|
"Can't rename file '%s' to '%s': %s" %
|
||||||
(filename, newfilename, e[1]),
|
(filename, newfilename, e.errno),
|
||||||
OfflineImapError.ERROR.FOLDER,
|
OfflineImapError.ERROR.FOLDER,
|
||||||
exc_info()[2])
|
exc_info()[2])
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import fcntl
|
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
@ -29,6 +28,14 @@ from offlineimap import OfflineImapError
|
|||||||
from offlineimap.ui import getglobalui
|
from offlineimap.ui import getglobalui
|
||||||
from imaplib2 import IMAP4, IMAP4_SSL, InternalDate
|
from imaplib2 import IMAP4, IMAP4_SSL, InternalDate
|
||||||
|
|
||||||
|
try:
|
||||||
|
import portalocker
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
import fcntl
|
||||||
|
except:
|
||||||
|
pass # Ok if this fails, we can do without.
|
||||||
|
|
||||||
|
|
||||||
class UsefulIMAPMixIn:
|
class UsefulIMAPMixIn:
|
||||||
def __getselectedfolder(self):
|
def __getselectedfolder(self):
|
||||||
|
@ -26,6 +26,7 @@ import collections
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import offlineimap
|
import offlineimap
|
||||||
|
from offlineimap.utils.distro_utils import get_os_name
|
||||||
import imaplib2 as imaplib
|
import imaplib2 as imaplib
|
||||||
|
|
||||||
# Ensure that `ui` gets loaded before `threadutil` in order to
|
# Ensure that `ui` gets loaded before `threadutil` in order to
|
||||||
@ -72,7 +73,18 @@ class OfflineImap:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def get_env_info(self):
|
def get_env_info(self):
|
||||||
info = "imaplib2 v%s, Python v%s" % (imaplib.__version__, PYTHON_VERSION)
|
# Transitional code between imaplib2 versions
|
||||||
|
try:
|
||||||
|
# imaplib2, previous versions, based on Python 2.x
|
||||||
|
l_imaplib_version = imaplib.__version__
|
||||||
|
except AttributeError:
|
||||||
|
# New imaplib2, version >= 3.06
|
||||||
|
l_imaplib_version = imaplib.version()
|
||||||
|
except:
|
||||||
|
# This should not happen
|
||||||
|
l_imaplib_version = " Unknown"
|
||||||
|
|
||||||
|
info = "imaplib2 v%s, Python v%s" % (l_imaplib_version, PYTHON_VERSION)
|
||||||
try:
|
try:
|
||||||
import ssl
|
import ssl
|
||||||
info = "%s, %s" % (info, ssl.OPENSSL_VERSION)
|
info = "%s, %s" % (info, ssl.OPENSSL_VERSION)
|
||||||
@ -446,6 +458,9 @@ class OfflineImap:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.num_sigterm = 0
|
self.num_sigterm = 0
|
||||||
|
|
||||||
|
# We cannot use signals in Windows
|
||||||
|
if get_os_name() != 'windows':
|
||||||
signal.signal(signal.SIGHUP, sig_handler)
|
signal.signal(signal.SIGHUP, sig_handler)
|
||||||
signal.signal(signal.SIGUSR1, sig_handler)
|
signal.signal(signal.SIGUSR1, sig_handler)
|
||||||
signal.signal(signal.SIGUSR2, sig_handler)
|
signal.signal(signal.SIGUSR2, sig_handler)
|
||||||
|
Loading…
Reference in New Issue
Block a user