diff --git a/fdroidserver/index.py b/fdroidserver/index.py index ff391abd..8ba53b88 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -133,21 +133,36 @@ def make(apps, apks, repodir, archive): make_website(sortedapps, repodir, repodict) +def _should_file_be_generated(path, magic_string): + if os.path.exists(path): + with open(path) as f: + if not magic_string in f.readline(): # if the magic_string is not in the first line the file should be overwritten + return False + return True + + def make_website(apps, repodir, repodict): _, repo_pubkey_fingerprint = extract_pubkey() repo_pubkey_fingerprint_stripped = repo_pubkey_fingerprint.replace(" ", "") link = repodict["address"] link_fingerprinted = "{link}?fingerprint={fingerprint}".format(link=link, fingerprint=repo_pubkey_fingerprint_stripped) + autogenerate_comment = "auto-generated - fdroid index updates will overwrite this file" # do not change this string, as it will break the updates for existing files with older versions of this string if not os.path.exists(repodir): os.makedirs(repodir) - html_name = 'index.html' + + qrcode.make(link_fingerprinted).save(os.path.join(repodir, "index.png")) + html_name = 'index.html' html_file = os.path.join(repodir, html_name) - with open(html_file, 'w') as f: - name = repodict["name"] - description = repodict["description"] - f.write(""" + + if _should_file_be_generated(html_file, autogenerate_comment): + with open(html_file, 'w') as f: + name = repodict["name"] + description = repodict["description"] + icon = repodict["icon"] + f.write(""" +
@@ -155,8 +170,8 @@ def make_website(apps, repodir, repodict):