Skip to content

Commit d7bc398

Browse files
committed
Fix flushdb to use the correct database path
Store db_path as instance variable to ensure flushdb deletes the actual database file being used, not just config.SQLITE_DB_PATH
1 parent 9271e24 commit d7bc398

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

addok_sqlite_store/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ def __init__(self, *args, **kwargs):
1111
self.init()
1212

1313
def init(self):
14-
db_path = (os.environ.get('ADDOK_SQLITE_DB_PATH') or
15-
os.environ.get('SQLITE_DB_PATH') or
16-
config.SQLITE_DB_PATH)
17-
self.conn = sqlite3.connect(db_path)
14+
self.db_path = (os.environ.get('ADDOK_SQLITE_DB_PATH') or
15+
os.environ.get('SQLITE_DB_PATH') or
16+
config.SQLITE_DB_PATH)
17+
self.conn = sqlite3.connect(self.db_path)
1818
self.lock = Lock()
1919
with self.conn as conn:
2020
conn.execute('CREATE TABLE IF NOT EXISTS '
@@ -48,7 +48,7 @@ def remove(self, *keys):
4848
self.lock.release()
4949

5050
def flushdb(self):
51-
os.unlink(config.SQLITE_DB_PATH)
51+
os.unlink(self.db_path)
5252
self.init()
5353

5454

0 commit comments

Comments
 (0)