Skip to content

Commit e5f28c4

Browse files
prandlaveluca93
authored andcommitted
Fix invalid use of FileCacher in DownloadTestcasesHandler
1 parent 1bd6222 commit e5f28c4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

cms/server/admin/handlers/dataset.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -621,15 +621,12 @@ def post(self, dataset_id):
621621
temp_file = io.BytesIO()
622622
with zipfile.ZipFile(temp_file, "w") as zip_file:
623623
for testcase in dataset.testcases.values():
624-
# Get input, output file path
625-
with self.service.file_cacher.get_file(testcase.input) as f:
626-
input_path = f.name
627-
with self.service.file_cacher.get_file(testcase.output) as f:
628-
output_path = f.name
629-
zip_file.write(
630-
input_path, input_template % testcase.codename)
631-
zip_file.write(
632-
output_path, output_template % testcase.codename)
624+
# Copy input file
625+
with zip_file.open(input_template % testcase.codename, 'w') as fout:
626+
self.service.file_cacher.get_file_to_fobj(testcase.input, fout)
627+
# Copy output file
628+
with zip_file.open(output_template % testcase.codename, 'w') as fout:
629+
self.service.file_cacher.get_file_to_fobj(testcase.output, fout)
633630

634631
self.set_header("Content-Type", "application/zip")
635632
self.set_header("Content-Disposition",

0 commit comments

Comments
 (0)