Skip to content

Commit 5542328

Browse files
committed
get_db_files_base_dir
1 parent 72a391b commit 5542328

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

qiita_db/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ def get_db_files_base_dir():
410410
"""
411411
with qdb.sql_connection.TRN:
412412
qdb.sql_connection.TRN.add("SELECT base_data_dir FROM settings")
413-
return qdb.sql_connection.TRN.execute_fetchlast()
413+
basedir = qdb.sql_connection.TRN.execute_fetchlast()
414+
# making sure that it never ends in a "/" as most tests expect this
415+
if basedir.endswith("/"):
416+
basedir = basedir[:-1]
417+
return basedir
414418

415419

416420
def get_work_base_dir():

qiita_pet/handlers/download.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ def _list_dir_files_nginx(self, dirpath):
7676
directory
7777
"""
7878
basedir = get_db_files_base_dir()
79-
basedir_len = len(basedir)
80-
if not basedir.endswith('/'):
81-
basedir_len += 1
79+
basedir_len = len(basedir) + 1
8280
to_download = []
8381
for dp, _, fps in walk(dirpath):
8482
for fn in fps:
@@ -103,9 +101,7 @@ def _list_artifact_files_nginx(self, artifact):
103101
The path information needed by nginx for each file in the artifact
104102
"""
105103
basedir = get_db_files_base_dir()
106-
basedir_len = len(basedir)
107-
if not basedir.endswith('/'):
108-
basedir_len += 1
104+
basedir_len = len(basedir) + 1
109105
to_download = []
110106
for i, x in enumerate(artifact.filepaths):
111107
# ignore if tgz as they could create problems and the
@@ -432,9 +428,7 @@ def get(self):
432428
sort='descending')[0]
433429

434430
basedir = get_db_files_base_dir()
435-
basedir_len = len(basedir)
436-
if not basedir.endswith('/'):
437-
basedir_len += 1
431+
basedir_len = len(basedir) + 1
438432
fp = x['fp'][basedir_len:]
439433
to_download.append((fp, fp, '-', str(x['fp_size'])))
440434
self._write_nginx_file_list(to_download)

0 commit comments

Comments
 (0)