Skip to content

Commit f4625f4

Browse files
committed
progressive download: made progressive_download.txt error handling more robust, allow empty lines
1 parent bda5e69 commit f4625f4

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

launcher/game/web.rpy

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,26 @@ init python:
109109
)
110110

111111
# Parse rules
112+
line_no = 0
112113
for line in open(rules_path, 'r').readlines():
113-
if line.startswith('#'):
114+
line_no += 1
115+
116+
if line.startswith('#') or line.strip() == '':
114117
continue
115-
(f_rule, f_type, f_pattern) = line.rstrip("\r\n").split(' ', 3-1)
116-
f_rule = {'+': True, '-': False}.get(f_rule)
118+
119+
try:
120+
(f_rule, f_type, f_pattern) = line.rstrip("\r\n").split(' ', 3-1)
121+
except ValueError:
122+
raise RuntimeError("Missing element at progressive_download.txt:%d" % line_no)
123+
124+
try:
125+
f_rule = {'+': True, '-': False}[f_rule]
126+
except KeyError:
127+
raise RuntimeError("Invalid rule '%s' at progressive_download.txt:%d" % (f_rule, line_no))
128+
129+
if f_type not in ('image', 'music', 'voice'):
130+
raise RuntimeError("Invalid type '%s' at progressive_download.txt:%d" % (f_type, line_no))
131+
117132
path_filters.append((f_rule, f_type, f_pattern))
118133

119134
def filters_match(path_filters, path, path_type):

0 commit comments

Comments
 (0)