mirror of https://tt-rss.org/git/tt-rss.git
Rework 'RSSUtils::cleanup_feed_icons' to only target expected files.
Prior to this '.', '..', and '.no-auto-expiry' were targeted, and the 'unlink()' was targeting files in the working directory.
This commit is contained in:
parent
292ca86665
commit
a57f4e6da7
|
@ -40,26 +40,22 @@ class RSSUtils {
|
|||
$cache = new DiskCache('feed-icons');
|
||||
|
||||
if ($cache->is_writable()) {
|
||||
$dh = opendir($cache->get_full_path(""));
|
||||
$icons = array_map('basename', glob($cache->get_full_path('*')) ?: []);
|
||||
|
||||
if ($dh) {
|
||||
while (($icon = readdir($dh)) !== false) {
|
||||
if ($cache->get_mtime($icon) < time() - 86400 * Config::get(Config::CACHE_MAX_DAYS)) {
|
||||
foreach ($icons as $icon) {
|
||||
if ($cache->get_mtime($icon) < time() - 86400 * Config::get(Config::CACHE_MAX_DAYS)) {
|
||||
|
||||
$sth->execute([(int)$icon]);
|
||||
$sth->execute([(int)$icon]);
|
||||
|
||||
if ($sth->fetch()) {
|
||||
$cache->put($icon, $cache->get($icon));
|
||||
} else {
|
||||
$icon_path = $cache->get_full_path($icon);
|
||||
if ($sth->fetch()) {
|
||||
$cache->put($icon, $cache->get($icon));
|
||||
} else {
|
||||
$icon_path = $cache->get_full_path($icon);
|
||||
|
||||
Debug::log("Removing orphaned feed icon: $icon_path");
|
||||
unlink($icon);
|
||||
}
|
||||
Debug::log("Removing orphaned feed icon: $icon_path");
|
||||
$cache->remove($icon);
|
||||
}
|
||||
}
|
||||
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue