aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2018-11-29 10:37:39 +0100
committerMax Kostikov <max@kostikov.co>2018-11-29 10:37:39 +0100
commit476bd7400d2e693fb9ef1f6868a6d9c43efd9def (patch)
tree6570b68b3f9535a57eee831909b9cec8d8060d52 /Zotlabs
parentbd10d48338ef7465d186b44c0982b81503ac861b (diff)
downloadvolse-hubzilla-476bd7400d2e693fb9ef1f6868a6d9c43efd9def.tar.gz
volse-hubzilla-476bd7400d2e693fb9ef1f6868a6d9c43efd9def.tar.bz2
volse-hubzilla-476bd7400d2e693fb9ef1f6868a6d9c43efd9def.zip
Add photo cache cleanup
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Cron.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index 25e49b817..8b6b42c8a 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -94,6 +94,29 @@ class Cron {
@time_sleep_until(microtime(true) + (float) $interval);
}
}
+
+ // Clean expired photos from cache
+
+ $age = get_config('system','active_expire_days', '30');
+ $r = q("SELECT DISTINCT xchan, content FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
+ intval(PHOTO_CACHE),
+ db_utcnow(),
+ db_quoteinterval($age . ' DAY')
+ );
+ if($r) {
+ foreach($r as $rr) {
+ $file = dbunescbin($rr['content']);
+ if(is_file($file)) {
+ @unlink($file);
+ logger('info: deleted cached photo file ' . $file, LOGGER_DEBUG);
+ }
+ }
+ }
+ q("DELETE FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
+ intval(PHOTO_CACHE),
+ db_utcnow(),
+ db_quoteinterval($age . ' DAY')
+ );
// publish any applicable items that were set to be published in the future
// (time travel posts). Restrict to items that have come of age in the last