fix(flash): increase INT_WDT timeout, enable littlefs wdt reset and thread safety
All checks were successful
ESP32 Build & Release / build (push) Successful in 1m11s
All checks were successful
ESP32 Build & Release / build (push) Successful in 1m11s
This commit is contained in:
@@ -224,7 +224,9 @@ static esp_err_t http_get_json(const char *url, char **out_buf)
|
||||
|
||||
static esp_err_t http_download_file(const char *url, const char *path)
|
||||
{
|
||||
FILE *f = fopen(path, "wb");
|
||||
char tmp[128];
|
||||
snprintf(tmp, sizeof(tmp), "%s.tmp", path);
|
||||
FILE *f = fopen(tmp, "wb");
|
||||
if (f == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -232,9 +234,14 @@ static esp_err_t http_download_file(const char *url, const char *path)
|
||||
esp_err_t ret = http_request(url, &sink);
|
||||
fclose(f);
|
||||
if (ret != ESP_OK) {
|
||||
remove(path);
|
||||
remove(tmp);
|
||||
return ret;
|
||||
}
|
||||
remove(path);
|
||||
if (rename(tmp, path) != 0) {
|
||||
remove(tmp);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -397,9 +404,11 @@ static esp_err_t scryfall_do_fetch(const char *card_name, const char *uid)
|
||||
if (image_url && strlen(image_url) > 0) {
|
||||
char jpg_path[64];
|
||||
snprintf(jpg_path, sizeof(jpg_path), STORAGE_CARDS_DIR "/%s.jpg", uid);
|
||||
char enc_img[512];
|
||||
url_encode(image_url, enc_img, sizeof(enc_img));
|
||||
char proxy_url[600];
|
||||
/* wsrv.nl converts Scryfall's progressive JPEG to a lightweight 200x110 baseline JPEG */
|
||||
snprintf(proxy_url, sizeof(proxy_url), "https://wsrv.nl/?url=%s&w=200&h=110&fit=cover&output=jpg", image_url);
|
||||
snprintf(proxy_url, sizeof(proxy_url), "https://wsrv.nl/?url=%s&w=200&h=110&fit=cover&output=jpg", enc_img);
|
||||
esp_err_t dl = http_download_file(proxy_url, jpg_path);
|
||||
if (dl != ESP_OK) {
|
||||
ESP_LOGW(TAG, "proxied image download failed, trying direct: %s", image_url);
|
||||
|
||||
Reference in New Issue
Block a user