Skip to content

Commit fb1737d

Browse files
committed
Merge pull request #1439 from ElDeveloper/path-fix
BUG: Fix problem with default basedir
2 parents a03564a + 35d5231 commit fb1737d

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

qiita_core/configuration_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ def __init__(self):
144144
def _get_main(self, config):
145145
"""Get the configuration of the main section"""
146146
self.test_environment = config.getboolean('main', 'TEST_ENVIRONMENT')
147-
default_base_data_dir = join(dirname(abspath(__file__)),
148-
'..', 'qiita_db', 'support_files',
147+
install_dir = dirname(dirname(abspath(__file__)))
148+
default_base_data_dir = join(install_dir, 'qiita_db', 'support_files',
149149
'test_data')
150150
self.base_data_dir = config.get('main', 'BASE_DATA_DIR') or \
151151
default_base_data_dir

qiita_db/support_files/patches/31.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- August 24, 2015
2+
-- Delete all occurrences of '..' in the base_data_dir entry
3+
SELECT 42;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from os.path import realpath
2+
from qiita_db.sql_connection import TRN
3+
4+
with TRN:
5+
TRN.add('SELECT base_data_dir FROM settings')
6+
path = TRN.execute_fetchlast()
7+
8+
# if the path is non-canonical (it contains .. or other redundant symbols)
9+
# this will update it, else it will leave as is
10+
TRN.add("UPDATE settings SET base_data_dir = %s", (realpath(path),))
11+
TRN.execute()

0 commit comments

Comments
 (0)