summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-08-28 09:21:08 +0300
committerAndrew Dolgov <[email protected]>2023-08-28 09:21:08 +0300
commite78a69f8cd556864da49919f97647aed372f00e0 (patch)
treec14ad7c5902783073474ca3b9dc906d451599c07
parentfe7db65b676d467a227bb895dce7d67047b59eca (diff)
fix flagfile not created before invoking GD
-rwxr-xr-xinit.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/init.php b/init.php
index 70f43f5..fbba819 100755
--- a/init.php
+++ b/init.php
@@ -297,10 +297,12 @@ class Af_Img_Phash extends Plugin {
if ($this->cache->is_writable()) {
- // check for .flag & create it
+ // check for .flag to prevent repeated failures or create it
if ($this->cache->exists($cached_file_flag)) {
Debug::log("phash: $cached_file_flag exists, looks like we failed on this URL before; skipping.", Debug::LOG_VERBOSE);
continue;
+ } else {
+ $this->cache->put($cached_file_flag, "");
}
// check for local cache
@@ -325,9 +327,7 @@ class Af_Img_Phash extends Plugin {
Debug::log("phash: calculated perceptual hash: $hash", Debug::LOG_VERBOSE);
// we managed to process this image, it should be safe to remove the flag now
- // @phpstan-ignore-next-line
- if ($this->cache->is_writable() && $this->cache->exists($cached_file_flag))
- unlink($this->cache->get_full_path($cached_file_flag));
+ $this->cache->remove($cached_file_flag);
if ($hash) {
$hash = base_convert($hash, 16, 10);