rev 352 - in offlineimap/head: debian offlineimap offlineimap/ui
[email protected] Wed, 29 Jan 2003 13:19:54 -0600 (CST)
| Newsgroups | gmane.mail.imap.offlineimap.subversion |
|---|---|
| Message-ID | <[email protected]> |
Author: jgoerzen
Date: 2003-01-29 13:19:53 -0600 (Wed, 29 Jan 2003)
New Revision: 352
Modified:
offlineimap/head/debian/changelog
offlineimap/head/offlineimap/init.py
offlineimap/head/offlineimap/ui/UIBase.py
Log:
* Added check to make sure that two processes do not run in the same
directory at once.
Modified: offlineimap/head/debian/changelog
==============================================================================
--- offlineimap/head/debian/changelog (original)
+++ offlineimap/head/debian/changelog Wed Jan 29 13:19:54 2003
@@ -1,3 +1,10 @@
+offlineimap (3.99.9) unstable; urgency=low
+
+ * Added check to make sure that two processes do not run in the same
+ directory at once.
+
+ -- John Goerzen <[email protected]> Wed, 29 Jan 2003 13:19:14 -0600
+
offlineimap (3.99.8) unstable; urgency=low
* This is a 4.0 TRACK release, and may be unstable or in flux!
Modified: offlineimap/head/offlineimap/init.py
==============================================================================
--- offlineimap/head/offlineimap/init.py (original)
+++ offlineimap/head/offlineimap/init.py Wed Jan 29 13:19:54 2003
@@ -20,11 +20,22 @@
from offlineimap.localeval import LocalEval
from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
from offlineimap.ui import UIBase
-import re, os, os.path, offlineimap, sys
+import re, os, os.path, offlineimap, sys, fcntl
from offlineimap.CustomConfig import CustomConfigParser
from threading import *
from getopt import getopt
+lockfd = None
+
+def lock(config, ui):
+ global lockfd
+ lockfd = open(config.getmetadatadir() + "/lock", "w")
+ try:
+ fcntl.flock(lockfd, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError:
+ ui.locked()
+ ui.terminate(1)
+
def startup(versionno):
assert versionno == version.versionstr, "Revision of main program (%d) does not match that of library (%d). Please double-check your PYTHONPATH and installation locations." % (revno, version.revno)
options = {}
@@ -71,6 +82,8 @@
if '-o' in options:
for section in config.getaccountlist():
config.remove_option(section, "autorefresh")
+
+ lock(config, ui)
accounts = config.get("general", "accounts")
if '-a' in options:
Modified: offlineimap/head/offlineimap/ui/UIBase.py
==============================================================================
--- offlineimap/head/offlineimap/ui/UIBase.py (original)
+++ offlineimap/head/offlineimap/ui/UIBase.py Wed Jan 29 13:19:54 2003
@@ -101,6 +101,9 @@
def invaliddebug(s, debugtype):
s.warn("Invalid debug type: %s" % debugtype)
+ def locked(s):
+ s.warn("Another OfflineIMAP is running with the same metadatadir; exiting.")
+
def getnicename(s, object):
prelimname = str(object.__class__).split('.')[-1]
# Strip off extra stuff.