Skip to content

Commit 3e55b90

Browse files
authored
Merge pull request #69 from mattip/download-data_2
keep file open
2 parents 1dd5461 + 4f4c919 commit 3e55b90

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

codespeed/admin_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ def download_db(request):
158158
try:
159159
_build_sqlite(path)
160160
f = open(path, 'rb')
161-
os.unlink(path) # unlink now; data survives until f is closed
162161
today = datetime.today().strftime('%Y-%m-%d')
163162
response = FileResponse(
164163
f,
165164
as_attachment=True,
166165
filename=f'codespeed-{today}.sqlite3',
167166
)
167+
os.unlink(path) # unlink after FileResponse reads the file size
168168
response.set_cookie(
169169
'codespeed_download_ready', '1',
170170
max_age=60, path='/', samesite='Lax',

0 commit comments

Comments
 (0)