migrate favicons directly to new cache

This commit is contained in:
Andrew Dolgov 2022-11-24 23:43:46 +03:00
parent a30b9bb649
commit 3212c51ce8
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
1 changed files with 4 additions and 3 deletions

View File

@ -1695,15 +1695,16 @@ class RSSUtils {
$dh = opendir($old_dir);
$cache = new DiskCache('feed-icons');
if ($dh) {
while (($old_filename = readdir($dh)) !== false) {
if (strpos($old_filename, ".ico") !== false) {
$new_filename = str_replace(".ico", "", $old_filename);
$old_full_path = "$old_dir/$old_filename";
$new_full_path = "$new_dir/$new_filename";
if (is_file($old_full_path) && !file_exists($new_full_path)) {
rename($old_full_path, $new_full_path);
if (is_file($old_full_path) && $cache->put($new_filename, file_get_contents($old_full_path))) {
unlink($old_full_path);
}
}
}