/offlineimap/head: changeset 352

Added check to make sure that two processes do not run in the same
directory at once.
This commit is contained in:
jgoerzen 2003-01-30 02:19:53 +01:00
parent 897e93700d
commit 7b9b102e5e
3 changed files with 24 additions and 1 deletions

View File

@ -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 <jgoerzen@complete.org> 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!

View File

@ -20,11 +20,22 @@ from offlineimap import imaplib, imapserver, repository, folder, mbnames, thread
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 = {}
@ -72,6 +83,8 @@ def startup(versionno):
for section in config.getaccountlist():
config.remove_option(section, "autorefresh")
lock(config, ui)
accounts = config.get("general", "accounts")
if '-a' in options:
accounts = options['-a']

View File

@ -101,6 +101,9 @@ class UIBase:
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.