mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +01:00
Use tempfile.SpooledTemporaryFile() instead of raw BytesIO (#767)
* Use tempfile.SpooledTemporaryFile() instead of raw BytesIO * Fix test to call .read() instead of .getvalue()
This commit is contained in:
@@ -14,6 +14,7 @@ import os
|
||||
import re
|
||||
import six
|
||||
import zipfile
|
||||
import tempfile
|
||||
|
||||
|
||||
class CTFdSerializer(JSONSerializer):
|
||||
@@ -56,7 +57,7 @@ def export_ctf():
|
||||
db = dataset.connect(get_app_config('SQLALCHEMY_DATABASE_URI'))
|
||||
|
||||
# Backup database
|
||||
backup = six.BytesIO()
|
||||
backup = tempfile.SpooledTemporaryFile()
|
||||
|
||||
backup_zip = zipfile.ZipFile(backup, 'w')
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def test_export_ctf():
|
||||
backup = export_ctf()
|
||||
|
||||
with open('export.zip', 'wb') as f:
|
||||
f.write(backup.getvalue())
|
||||
f.write(backup.read())
|
||||
os.remove('export.zip')
|
||||
destroy_ctfd(app)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user