Skip to content

Commit 43dd7f5

Browse files
Merge pull request #521 from framasoft/fix-exportCSV-crash
Prevent crash "TypeError: Cannot read property 'exportCSV' of undefined"
2 parents 6d11dcf + da473d3 commit 43dd7f5

File tree

2 files changed

+51
-42
lines changed

2 files changed

+51
-42
lines changed

main.js

+32-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ls

+19-15
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,25 @@
107107
"""
108108
@response.send 200 content
109109
return
110-
csv <~ SC[room].exportCSV
111-
_, body <~ csv-parse(csv, delimiter: \,)
112-
body.shift! # header
113-
todo = DB.multi!
114-
names = []
115-
for [link, title], idx in body | link and title and link is /^\//
116-
names ++= title
117-
todo.=get "snapshot-#{ link.slice(1) }"
118-
_, saves <~ todo.exec!
119-
[type, content] = cb-multiple.call @params, names, saves
120-
@response.type type
121-
@response.set \Content-Disposition """
122-
attachment; filename="#room.xlsx"
123-
"""
124-
@response.send 200 content
110+
if SC[room] != undefined
111+
csv <~ SC[room].exportCSV
112+
_, body <~ csv-parse(csv, delimiter: \,)
113+
body.shift! # header
114+
todo = DB.multi!
115+
names = []
116+
for [link, title], idx in body | link and title and link is /^\//
117+
names ++= title
118+
todo.=get "snapshot-#{ link.slice(1) }"
119+
_, saves <~ todo.exec!
120+
[type, content] = cb-multiple.call @params, names, saves
121+
@response.type type
122+
@response.set \Content-Disposition """
123+
attachment; filename="#room.xlsx"
124+
"""
125+
@response.send 200 content
126+
else
127+
@response.type Text
128+
@response.send 404 ''
125129
else
126130
{snapshot} <~ SC._get room, IO
127131
if snapshot

0 commit comments

Comments
 (0)