mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-20 15:24:25 +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 re
|
||||||
import six
|
import six
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
class CTFdSerializer(JSONSerializer):
|
class CTFdSerializer(JSONSerializer):
|
||||||
@@ -56,7 +57,7 @@ def export_ctf():
|
|||||||
db = dataset.connect(get_app_config('SQLALCHEMY_DATABASE_URI'))
|
db = dataset.connect(get_app_config('SQLALCHEMY_DATABASE_URI'))
|
||||||
|
|
||||||
# Backup database
|
# Backup database
|
||||||
backup = six.BytesIO()
|
backup = tempfile.SpooledTemporaryFile()
|
||||||
|
|
||||||
backup_zip = zipfile.ZipFile(backup, 'w')
|
backup_zip = zipfile.ZipFile(backup, 'w')
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def test_export_ctf():
|
|||||||
backup = export_ctf()
|
backup = export_ctf()
|
||||||
|
|
||||||
with open('export.zip', 'wb') as f:
|
with open('export.zip', 'wb') as f:
|
||||||
f.write(backup.getvalue())
|
f.write(backup.read())
|
||||||
os.remove('export.zip')
|
os.remove('export.zip')
|
||||||
destroy_ctfd(app)
|
destroy_ctfd(app)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user