Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F16569612
D1690.id4492.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D1690.id4492.diff
View Options
diff --git a/pykolab/auth/ldap/auth_cache.py b/pykolab/auth/ldap/auth_cache.py
--- a/pykolab/auth/ldap/auth_cache.py
+++ b/pykolab/auth/ldap/auth_cache.py
@@ -17,6 +17,7 @@
#
import datetime
+import os
import sqlalchemy
@@ -84,6 +85,11 @@
db = init_db()
+ if db is None:
+ return
+
+ purge_entries()
+
try:
db.query(Entry).filter_by(key=key).delete()
except sqlalchemy.exc.OperationalError:
@@ -102,6 +108,9 @@
db = init_db()
+ if db is None:
+ return None
+
try:
_entries = db.query(Entry).filter_by(key=key).all()
except sqlalchemy.exc.OperationalError:
@@ -121,8 +130,14 @@
def set_entry(key, value):
+ # pylint: disable=global-statement
+ global db
+
db = init_db()
+ if db is None:
+ return
+
try:
_entries = db.query(Entry).filter_by(key=key).all()
except sqlalchemy.exc.OperationalError:
@@ -147,12 +162,18 @@
db.commit()
-def purge_entries(db):
- db.query(Entry).filter(
- Entry.last_change <= (datetime.datetime.now() - datetime.timedelta(1))
- ).delete()
+def purge_entries():
+ # pylint: disable=global-statement
+ global db
- db.commit()
+ try:
+ db.query(Entry).filter(
+ Entry.last_change <= (datetime.datetime.now() - datetime.timedelta(1))
+ ).delete()
+
+ db.commit()
+ except Exception:
+ return
def init_db(reinit=False):
@@ -167,11 +188,13 @@
db_uri = conf.get('ldap', 'auth_cache_uri')
+ if db_uri == "null":
+ return None
+
if db_uri is None:
db_uri = 'sqlite:///%s/auth_cache.db' % (KOLAB_LIB_PATH)
if reinit:
- import os
if os.path.isfile('%s/auth_cache.db' % (KOLAB_LIB_PATH)):
os.unlink('%s/auth_cache.db' % (KOLAB_LIB_PATH))
@@ -181,6 +204,5 @@
Session = sessionmaker(bind=engine)
db = Session()
- purge_entries(db)
return db
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 31, 8:37 AM (10 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10075095
Default Alt Text
D1690.id4492.diff (1 KB)
Attached To
Mode
D1690: Address stale cache entries
Attached
Detach File
Event Timeline
Log In to Comment