mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Revert "Use a temporary file for exports for more stable writing"
This commit is contained in:
@@ -19,8 +19,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
import inspect
|
||||
import tempfile
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.conf import settings
|
||||
@@ -63,24 +61,14 @@ def export(self, event: Event, fileid: str, provider: str, form_data: Dict[str,
|
||||
continue
|
||||
ex = response(event, event.organizer, set_progress)
|
||||
if ex.identifier == provider:
|
||||
with tempfile.TemporaryFile() as f:
|
||||
if 'output_file' in inspect.signature(ex.render).parameters:
|
||||
d = ex.render(form_data, output_file=f)
|
||||
f.seek(0)
|
||||
if d is None:
|
||||
raise ExportError(
|
||||
gettext('Your export did not contain any data.')
|
||||
)
|
||||
file.filename, file.type, data = d
|
||||
else:
|
||||
d = ex.render(form_data)
|
||||
if d is None:
|
||||
raise ExportError(
|
||||
gettext('Your export did not contain any data.')
|
||||
)
|
||||
file.filename, file.type, data = d
|
||||
f = ContentFile(data)
|
||||
file.file.save(cachedfile_name(file, file.filename), f)
|
||||
d = ex.render(form_data)
|
||||
if d is None:
|
||||
raise ExportError(
|
||||
gettext('Your export did not contain any data.')
|
||||
)
|
||||
file.filename, file.type, data = d
|
||||
f = ContentFile(data)
|
||||
file.file.save(cachedfile_name(file, file.filename), f)
|
||||
return file.pk
|
||||
|
||||
|
||||
@@ -141,22 +129,12 @@ def multiexport(self, organizer: Organizer, user: User, device: int, token: int,
|
||||
gettext('You do not have sufficient permission to perform this export.')
|
||||
)
|
||||
|
||||
with tempfile.TemporaryFile() as f:
|
||||
if 'output_file' in inspect.signature(ex.render).parameters:
|
||||
d = ex.render(form_data, output_file=f)
|
||||
f.seek(0)
|
||||
if d is None:
|
||||
raise ExportError(
|
||||
gettext('Your export did not contain any data.')
|
||||
)
|
||||
file.filename, file.type, data = d
|
||||
else:
|
||||
d = ex.render(form_data)
|
||||
file.filename, file.type, data = d
|
||||
if d is None:
|
||||
raise ExportError(
|
||||
gettext('Your export did not contain any data.')
|
||||
)
|
||||
f = ContentFile(data)
|
||||
file.file.save(cachedfile_name(file, file.filename), f)
|
||||
d = ex.render(form_data)
|
||||
if d is None:
|
||||
raise ExportError(
|
||||
gettext('Your export did not contain any data.')
|
||||
)
|
||||
file.filename, file.type, data = d
|
||||
f = ContentFile(data)
|
||||
file.file.save(cachedfile_name(file, file.filename), f)
|
||||
return file.pk
|
||||
|
||||
Reference in New Issue
Block a user