@@ -168,6 +168,25 @@ def get(self, requested_filepath):
168168 # a whole directory
169169 to_download = BaseHandlerDownload ._list_dir_files_nginx (
170170 self , filepath )
171+
172+ # fp_subdir is the part of the filepath the user requested,
173+ # without QIITA_BASE_DIR
174+ fp_subdir = os .path .relpath (filepath , basedatadir )
175+
176+ # above function adds filepath to located files, which is
177+ # different from the non-nginx version, e.g.
178+ # fp = /protected/job/2_test_folder/testdir/fileA.txt
179+ # fp_name = job/2_test_folder/testdir/fileA.txt
180+ # where "job/2_test_folder" is what user requested and
181+ # "testdir/fileA.txt" is a file within this directory.
182+ # When extracting by qiita_client, the "job/2_test_folder"
183+ # part would be added twice (one by user request, second by
184+ # unzipping). Therefore, we need to correct these names here:
185+ to_download = [
186+ (fp , os .path .relpath (fp_name , fp_subdir ), fp_checksum ,
187+ fp_size )
188+ for fp , fp_name , fp_checksum , fp_size
189+ in to_download ]
171190 BaseHandlerDownload ._write_nginx_file_list (self , to_download )
172191 BaseHandlerDownload ._set_nginx_headers (
173192 self , filename_directory )
0 commit comments