Picture: download URLs once at save-time, not on every poll
Previously check() re-fetched the configured image URL over HTTP on every poll (every 30 min by default). If the remote image ever came back even slightly byte-different between fetches -- common with dynamically-generated images -- that forced a real e-ink flash for no visible reason, since this panel has no partial refresh. Now the URL is downloaded exactly once, server-side in the settings route, and saved into web/static/uploads/current.<ext> the same way a direct upload already was -- clearing any previous upload/download first so switching sources doesn't accumulate orphaned files. check() just reads that local file regardless of whether it came from an upload or a URL, with zero network calls. Also added a browser User-Agent to the download request -- confirmed live that Wikimedia (plausibly a common source people would link to) 403s the default requests/python User-Agent as bot traffic, same class of issue as the EFA transit endpoints handled earlier. Verified end-to-end against real URLs: download+cache works, a second URL replaces rather than accumulates, and a settings-only save (no new URL entered) no longer wipes the cached picture.
This commit is contained in:
1 parent
45fb370279
commit
5889422c31
3 files changed
+74
-40
No files matched your search
@@ -6,17 +6,15 @@
|
||||
<div class="toast error">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% if settings.mode == "upload" and settings.uploaded_filename %}
|
||||
{% if settings.uploaded_filename %}
|
||||
<div class="card">
|
||||
<div class="section-label">Current picture</div>
|
||||
<div class="preview-wrap">
|
||||
<img class="preview" src="{{ url_for('static', filename='uploads/' + settings.uploaded_filename) }}" alt="current picture">
|
||||
</div>
|
||||
</div>
|
||||
{% elif settings.mode == "url" and settings.image_url %}
|
||||
<div class="card">
|
||||
<div class="section-label">Current picture</div>
|
||||
<p class="hint">Fetched from a URL: {{ settings.image_url }}</p>
|
||||
{% if settings.mode == "url" and settings.image_url %}
|
||||
<p class="hint">Downloaded from: {{ settings.image_url }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -35,7 +33,7 @@
|
||||
<div class="field">
|
||||
<label for="image_url">Image URL</label>
|
||||
<input type="text" id="image_url" name="image_url" placeholder="https://example.com/photo.jpg">
|
||||
<p class="hint">Re-fetched every 30 minutes. Leave both this and the upload above alone to just change the options below.</p>
|
||||
<p class="hint">Downloaded once and cached -- won't keep re-fetching, so this can't cause the panel to flash on its own. Enter a new URL any time to replace it. Leave both this and the upload above alone to just change the options below.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user