summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-09-01 07:17:10 +0300
committerAndrew Dolgov <[email protected]>2021-09-01 07:17:10 +0300
commit3f8275459884a731d47dfc9279bf2d2545117d6b (patch)
tree0598c4a85e7801b1284a3b84d540541f9f2152cb
parentdb3fcd22d6bf9bcc96958d91f94ec0c392807b86 (diff)
prevent repeated failures when working with cached media (OOM, etc)
-rw-r--r--init.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/init.php b/init.php
index 95e2405..7c22089 100644
--- a/init.php
+++ b/init.php
@@ -120,8 +120,16 @@ class Api_Resize_Media extends Plugin {
}
$local_filename = sha1($url);
+ $local_filename_flag = "$local_filename.api_resize-flag";
$quality = $this->host->get($this, "quality", self::DEFAULT_QUALITY);
+ if ($this->cache->exists($local_filename_flag)) {
+ Debug::log("[api_resize_media] $local_filename_flag exists, looks like we failed on this URL before; skipping.", Debug::LOG_VERBOSE);
+ return;
+ }
+
+ $this->cache->touch($local_filename_flag);
+
if (!$this->cache->exists($local_filename)) {
$data = fetch_file_contents(["url" => $url, "max_size" => Config::get(Config::MAX_CACHE_FILE_SIZE)]);