Skip to content

Commit 8cec302

Browse files
Merge pull request #3746 from raspberrypi/md5
Add md5 hash query param to images to bust the cache when we update one inplace
2 parents 2550303 + e617a82 commit 8cec302

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

documentation/asciidoc/services/connect/use.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ image::images/screen-sharing-end.png[width="80%"]
103103

104104
To turn off screen sharing, click the Connect system tray icon and unselect **Allow screen sharing**. Your Raspberry Pi remains signed into Connect, but you won't be able to create a screen sharing session from the Connect dashboard.
105105

106-
image:images/screen-sharing-disabled-desktop.png[width="80%"]
106+
image::images/screen-sharing-disabled-desktop.png[width="80%"]
107107

108108
Alternatively, you can disable screen sharing with the following command:
109109

@@ -168,7 +168,7 @@ image::images/remote-shell-end.png[width="80%"]
168168

169169
To turn off remote shell access, click the Connect system tray icon and unselect **Allow remote shell**. Your Raspberry Pi remains signed into Connect, but you won't be able to create a remote shell session from the Connect dashboard.
170170

171-
image:images/remote-shell-disabled-desktop.png[width="80%"]
171+
image::images/remote-shell-disabled-desktop.png[width="80%"]
172172

173173
Alternatively, you can disable remote shell access with the following command:
174174

scripts/create_build_adoc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def check_no_markdown(filename):
2121
if re.search(r'(\[.+?\]\(.+?\))', asciidoc):
2222
raise Exception("{} contains a Markdown-style link (i.e. '[title](url)' rather than 'url[title]')".format(filename))
2323

24-
2524
if __name__ == "__main__":
2625
index_json = sys.argv[1]
2726
config_yaml = sys.argv[2]
@@ -72,6 +71,12 @@ def check_no_markdown(filename):
7271
m = re.match(r'^(include::)(.+)(\[\]\n?)$', line)
7372
if m:
7473
line = m.group(1) + os.path.join('{includedir}/{parentdir}', m.group(2)) + m.group(3)
74+
# find all image references, append md5 hash at end to bust the cache if we change the image
75+
m = re.match(r'^(image::)(.+)(\[(.+)]\n?)$', line)
76+
if m:
77+
directory = os.path.dirname(os.path.abspath(src_adoc))
78+
image_hash = hashlib.md5(open(os.path.join(directory, m.group(2)),'rb').read()).hexdigest()
79+
line = m.group(1) + m.group(2) + '?hash=' + image_hash + m.group(3) + "\n"
7580
new_contents += line
7681

7782
with open(build_adoc, 'w') as out_fh:

scripts/create_build_adoc_include.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import re
66
import yaml
7+
import hashlib
78

89

910
def check_no_markdown(filename):
@@ -48,6 +49,13 @@ def check_no_markdown(filename):
4849
seen_header = True
4950
if github_edit is not None:
5051
line += edit_text + "\n\n"
52+
else:
53+
# find all image references, append md5 hash at end to bust the cache if we change the image
54+
m = re.match(r'^(image::)(.+)(\[(.+)]\n?)$', line)
55+
if m:
56+
directory = os.path.dirname(os.path.abspath(src_adoc))
57+
image_hash = hashlib.md5(open(os.path.join(directory, m.group(2)),'rb').read()).hexdigest()
58+
line = m.group(1) + m.group(2) + '?hash=' + image_hash + m.group(3) + "\n"
5159
new_contents += line
5260

5361
with open(build_adoc, 'w') as out_fh:

0 commit comments

Comments
 (0)