summaryrefslogtreecommitdiff
path: root/classes/rssutils.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-29 12:46:55 +0300
committerAndrew Dolgov <[email protected]>2020-09-29 12:46:55 +0300
commit15e8ee3471cd0cc9ab507caa8a602d75f9f6c7ba (patch)
treec9e291f2f81bd649798bdbc0ada1af96d4497e04 /classes/rssutils.php
parent82bc740363e8d9f3c7a070444b0d1fae45f837c7 (diff)
housekeeping: add task to cleanup orphan feed icons
Diffstat (limited to 'classes/rssutils.php')
-rwxr-xr-xclasses/rssutils.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index 6b0ae2c32..54113360a 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -29,6 +29,28 @@ class RSSUtils {
$pdo->query("DELETE FROM ttrss_feedbrowser_cache");
}
+ static function cleanup_feed_icons() {
+ $pdo = Db::pdo();
+ $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ?");
+
+ // check icon files once every CACHE_MAX_DAYS days
+ $icon_files = array_filter(glob(ICONS_DIR . "/*.ico"),
+ function($f) { return filemtime($f) < time() - 86400*CACHE_MAX_DAYS; });
+
+ foreach ($icon_files as $icon) {
+ $feed_id = basename($icon, ".ico");
+
+ $sth->execute([$feed_id]);
+
+ if ($sth->fetch()) {
+ @touch($icon);
+ } else {
+ Debug::log("Removing orphaned feed icon: $icon");
+ unlink($icon);
+ }
+ }
+ }
+
static function update_daemon_common($limit = DAEMON_FEED_LIMIT, $options = []) {
$schema_version = get_schema_version();
@@ -1564,6 +1586,7 @@ class RSSUtils {
self::expire_error_log();
self::expire_feed_archive();
self::cleanup_feed_browser();
+ self::cleanup_feed_icons();
Article::purge_orphans();
self::cleanup_counters_cache();