with self.db.transaction():
release.scan_files(basepath=basepath)
+
+ def get_file_by_filename(self, filename):
+ ret = self.db.get("SELECT * FROM files WHERE filename = %s", filename)
+
+ if ret:
+ return File(self.backend, None, ret.id, data=ret)
<ul>
{% for file in release.get_files_by_arch(arch) %}
<li>
- <a class="download-splash" href="{{ file.url }}"
- title="{{ "%s: %s" % ("SHA256" if file.sha256 else "SHA1", file.sha256 or file.sha1) }}">
+ <a class="download-splash" href="{{ file.url }}">
<span class="icon-text">
<span class="icon">
<i class="fas fa-download"></i>
$("a.download-splash").click(function(e) {
e.preventDefault();
- window.location = "/downloads/thank-you?file=" + this.href;
+ window.location = "/downloads/thank-you?url=" + this.href;
});
</script>
{% end %}
<h1 class="title">
Thank You For Choosing IPFire<span class="has-text-primary">_</span>
</h1>
- <h4 class="subtitle">{{ _("Your download will begin shortly.") }}</h4>
+ <h4 class="subtitle">{{ _("Your download will begin shortly") }}</h4>
<div class="block">
- <p class="download-path"></p>
+ <a href="{{ file.url }}">{{ file.url }}</a>
+ </div>
+
+ <div class="block">
+ <p>
+ {{ _("After download, please verify the file has the following %s checksum:") % ("SHA-256" if file.sha256 else "SHA-1") }}
+ <span class="is-family-monospace">{{ file.sha256 or file.sha1 }}</span>
+ </p>
</div>
</div>
</div>
{% block javascript %}
<script type="text/javascript">
- $("p.download-path").ready(function() {
- const params = new URLSearchParams(window.location.search);
-
- var file = params.get("file");
-
- // Avoid downloading files from other websites
- if (!file.startsWith("https://downloads.ipfire.org/"))
- return;
-
- $("p.download-path").prepend($("<a>", {
- href: encodeURI(file),
- text: file
- }));
-
- setTimeout(function() {
- window.location = file
- }, "2000");
- });
+ setTimeout(function() {
+ window.location = "{{ file.url }}"
+ }, "2000");
</script>
{% end %}
class ThankYouHandler(base.AnalyticsMixin, base.BaseHandler):
def get(self):
- self.render("downloads/thank-you.html")
+ url = self.get_argument("url")
+
+ # Send 400 if URL is wrong
+ if not url.startswith("https://downloads.ipfire.org/"):
+ raise tornado.web.HTTPError(400)
+
+ filename = url.removeprefix("https://downloads.ipfire.org/")
+
+ # Get file by URL
+ file = self.backend.releases.get_file_by_filename(filename)
+ if not file:
+ raise tornado.web.HTTPError(404)
+
+ self.render("downloads/thank-you.html", file=file)
class FileHandler(base.AnalyticsMixin, base.BaseHandler):