mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-21 03:02:09 +00:00
Check for db first and clear sessions to force re-login
This commit is contained in:
parent
a7023d3758
commit
2e4d825b6e
@ -149,27 +149,38 @@ def migration_11(env):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def migration_12(env):
|
def migration_12(env):
|
||||||
# Upgrading from Carddav Roundcube plugin to version 3+ requires the carddav_
|
# Upgrading to Carddav Roundcube plugin to version 3+, it requires the carddav_*
|
||||||
# tables to be dropped
|
# tables to be dropped.
|
||||||
import sqlite3
|
# Checking that the roundcube database already exists.
|
||||||
conn = sqlite3.connect(os.path.join(env["STORAGE_ROOT"], "mail/roundcube/roundcube.sqlite"))
|
if os.path.exists(os.path.join(env["STORAGE_ROOT"], "mail/roundcube/roundcube.sqlite")):
|
||||||
c = conn.cursor()
|
import sqlite3
|
||||||
# Get a list of all the tables that begin with 'carddav_'
|
conn = sqlite3.connect(os.path.join(env["STORAGE_ROOT"], "mail/roundcube/roundcube.sqlite"))
|
||||||
c.execute("SELECT name FROM sqlite_master WHERE type = ? AND name LIKE ?", ('table', 'carddav_%'))
|
c = conn.cursor()
|
||||||
carddav_tables = c.fetchall()
|
# Get a list of all the tables that begin with 'carddav_'
|
||||||
# If there were tables that begin with 'carddav_', drop them
|
c.execute("SELECT name FROM sqlite_master WHERE type = ? AND name LIKE ?", ('table', 'carddav_%'))
|
||||||
if carddav_tables:
|
carddav_tables = c.fetchall()
|
||||||
for table in carddav_tables:
|
# If there were tables that begin with 'carddav_', drop them
|
||||||
try:
|
if carddav_tables:
|
||||||
table = table[0]
|
for table in carddav_tables:
|
||||||
c = conn.cursor()
|
try:
|
||||||
dropcmd = "DROP TABLE %s" % table
|
table = table[0]
|
||||||
c.execute(dropcmd)
|
c = conn.cursor()
|
||||||
except:
|
dropcmd = "DROP TABLE %s" % table
|
||||||
print("Failed to drop table", table, e)
|
c.execute(dropcmd)
|
||||||
# Save.
|
except:
|
||||||
conn.commit()
|
print("Failed to drop table", table, e)
|
||||||
conn.close()
|
# Save.
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
# Delete all sessions, requring users to login again to recreate carddav_*
|
||||||
|
# databases
|
||||||
|
conn = sqlite3.connect(os.path.join(env["STORAGE_ROOT"], "mail/roundcube/roundcube.sqlite"))
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute("delete from session;")
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
def get_current_migration():
|
def get_current_migration():
|
||||||
ver = 0
|
ver = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user