Skip to content

Commit a79b528

Browse files
committed
Fixes cache control for dev-debug mode
Updates the handling of cache control headers in dev-debug mode. The `nocache` variable is changed to an array to correctly pass multiple headers to `curl`. This resolves issues with cached versions of files being used when dev-debug is enabled, ensuring that the latest versions are always fetched. Fixes #4696
1 parent b3d2700 commit a79b528

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

lgsm/modules/command_update_linuxgsm.sh

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ info_distro.sh
1616
info_game.sh
1717

1818
# Prevent github from using a cached version of the file if dev-debug is enabled.
19+
nocache=()
1920
if [ -f "${rootdir}/.dev-debug" ]; then
20-
nocache="-H \"Cache-Control: no-cache\" -H \"Pragma: no-cache\""
21+
nocache=(-H "Cache-Control: no-cache" -H "Pragma: no-cache")
2122
fi
2223

2324
fn_script_log_info "Updating LinuxGSM"
@@ -26,10 +27,10 @@ fn_print_dots "Selecting repo"
2627
fn_script_log_info "Selecting repo"
2728
# Select remotereponame
2829

29-
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
30+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
3031
exitcode=$?
3132
if [ "${exitcode}" -ne "0" ]; then
32-
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
33+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
3334
exitcode=$?
3435
if [ "${exitcode}" -ne "0" ]; then
3536
fn_print_fail_nl "Selecting repo: Unable to to access GitHub or Bitbucket repositories"
@@ -47,9 +48,9 @@ fi
4748
# Check linuxsm.sh
4849
echo -en "checking ${remotereponame} script [ ${italic}linuxgsm.sh${default} ]\c"
4950
if [ "${remotereponame}" == "GitHub" ]; then
50-
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
51+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
5152
else
52-
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
53+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
5354
fi
5455
exitcode=$?
5556
if [ "${exitcode}" -ne 0 ]; then
@@ -60,9 +61,9 @@ if [ "${exitcode}" -ne 0 ]; then
6061
fi
6162

6263
if [ "${remotereponame}" == "GitHub" ]; then
63-
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
64+
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
6465
else
65-
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh"))
66+
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh"))
6667
fi
6768

6869
if [ "${tmp_script_diff}" != "" ]; then
@@ -130,9 +131,9 @@ fi
130131
echo -en "checking ${remotereponame} config [ ${italic}_default.cfg${default} ]\c"
131132
fn_script_log_info "Checking ${remotereponame} config _default.cfg"
132133
if [ "${remotereponame}" == "GitHub" ]; then
133-
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
134+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
134135
else
135-
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
136+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
136137
fi
137138
exitcode=$?
138139
if [ "${exitcode}" -ne 0 ]; then
@@ -143,9 +144,9 @@ if [ "${exitcode}" -ne 0 ]; then
143144
fi
144145

145146
if [ "${remotereponame}" == "GitHub" ]; then
146-
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
147+
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
147148
else
148-
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
149+
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
149150
fi
150151

151152
if [ "${config_file_diff}" != "" ]; then
@@ -165,9 +166,9 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
165166
echo -en "checking ${remotereponame} config [ ${italic}${distroid}-${distroversioncsv}.csv${default} ]\c"
166167
fn_script_log_info "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv"
167168
if [ "${remotereponame}" == "GitHub" ]; then
168-
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
169+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
169170
else
170-
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
171+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
171172
fi
172173
exitcode=$?
173174
if [ "${exitcode}" -ne 0 ]; then
@@ -178,9 +179,9 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
178179
fi
179180

180181
if [ "${remotereponame}" == "GitHub" ]; then
181-
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
182+
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
182183
else
183-
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
184+
config_file_diff=$(diff "${datadir}/${distroid}-${distroversioncsv}.csv" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv"))
184185
fi
185186

186187
if [ "${config_file_diff}" != "" ]; then
@@ -204,9 +205,9 @@ if [ -n "${modulesdir}" ]; then
204205
echo -en "checking ${remotereponame} module [ ${italic}${modulefile}${default} ]\c"
205206
github_file_url_dir="lgsm/modules"
206207
if [ "${remotereponame}" == "GitHub" ]; then
207-
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
208+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
208209
else
209-
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
210+
curl "${nocache[@]}" --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
210211
fi
211212
exitcode=$?
212213
if [ "${exitcode}" -ne 0 ]; then
@@ -224,9 +225,9 @@ if [ -n "${modulesdir}" ]; then
224225
else
225226
# compare file
226227
if [ "${remotereponame}" == "GitHub" ]; then
227-
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl ${nocache} --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}"))
228+
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}"))
228229
else
229-
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl ${nocache} --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}"))
230+
module_file_diff=$(diff "${modulesdir}/${modulefile}" <(curl "${nocache[@]}" --connect-timeout 3 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}"))
230231
fi
231232

232233
# results

0 commit comments

Comments
 (0)