diff options
author | Andrew Dolgov <[email protected]> | 2021-09-01 07:17:10 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-09-01 07:17:10 +0300 |
commit | 3f8275459884a731d47dfc9279bf2d2545117d6b (patch) | |
tree | 0598c4a85e7801b1284a3b84d540541f9f2152cb | |
parent | db3fcd22d6bf9bcc96958d91f94ec0c392807b86 (diff) |
prevent repeated failures when working with cached media (OOM, etc)
-rw-r--r-- | init.php | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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)]); |