summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-11-24 08:46:31 +0300
committerAndrew Dolgov <[email protected]>2022-11-24 08:46:31 +0300
commita40cb9881e649556aba5a196456f00663a8b0ee5 (patch)
treeb89b9a5e66e2709794a5505803496fbfb4c19902
parent5965900c7638d9c2dfcd384be5fa01f935523494 (diff)
stop using DiskCache->touch()
-rw-r--r--init.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/init.php b/init.php
index 0504b56..c871c6d 100644
--- a/init.php
+++ b/init.php
@@ -137,7 +137,8 @@ class Api_Resize_Media extends Plugin {
return;
}
- $this->cache->touch($local_filename_flag);
+ if (!$this->cache->exists($local_filename_flag))
+ $this->cache->put($local_filename_flag, "");
if (!$this->cache->exists($local_filename)) {
$data = UrlHelper::fetch(["url" => $url, "max_size" => Config::get(Config::MAX_CACHE_FILE_SIZE)]);
@@ -293,7 +294,12 @@ class Api_Resize_Media extends Plugin {
if ($this->cache->exists($local_filename)) {
return $this->cache->get_url($local_filename);
} else {
- if ($this->cache->touch(sha1($url) . ".flag")) {
+ $flag = sha1($url) . ".flag";
+
+ if (!$this->cache->exists($flag))
+ $this->cache->put($flag, "");
+
+ if ($this->cache->exists($flag)) {
return $this->host->get_public_method_url($this, "api_resize",
["url" => $url, "width" => $width, "force_stamp" => $force_stamp]);
}