summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrdalverny <rdalverny@gmail.com>2022-01-22 21:41:44 +0100
committerrdalverny <rdalverny@gmail.com>2022-01-22 21:41:44 +0100
commit1ebace1417563a74967e0c45fb3998a26770eb47 (patch)
treeadf45a00e3a077047a350a7763b0a52a2ce4ad1b
parent5a0c2d333ff41ec4da6a4d58bc1553beeee1affa (diff)
downloadplanet-1ebace1417563a74967e0c45fb3998a26770eb47.tar
planet-1ebace1417563a74967e0c45fb3998a26770eb47.tar.gz
planet-1ebace1417563a74967e0c45fb3998a26770eb47.tar.bz2
planet-1ebace1417563a74967e0c45fb3998a26770eb47.tar.xz
planet-1ebace1417563a74967e0c45fb3998a26770eb47.zip
Prune cached HTML when changing feeds list
-rw-r--r--app/classes/Cache.php15
-rwxr-xr-xpublic/admin/subscriptions.php6
2 files changed, 21 insertions, 0 deletions
diff --git a/app/classes/Cache.php b/app/classes/Cache.php
index 474c560..6a5b7e7 100644
--- a/app/classes/Cache.php
+++ b/app/classes/Cache.php
@@ -115,6 +115,21 @@ class Cache
return false;
}
+
+ public static function prune(string $group, ?string $id = null) : void
+ {
+ if (is_null($id)) {
+ $filenames = glob(self::$store . self::$prefix . "{$group}_*");
+ } else {
+ $filenames = [self::getFilename($group, $id)];
+ }
+
+ foreach ($filenames as $filename) {
+ if (is_file($filename)) {
+ unlink($filename);
+ }
+ }
+ }
/**
* Builds a filename/path from group, id and
diff --git a/public/admin/subscriptions.php b/public/admin/subscriptions.php
index 418e354..236ac46 100755
--- a/public/admin/subscriptions.php
+++ b/public/admin/subscriptions.php
@@ -22,6 +22,9 @@ if (isset($_POST['upload']) &&
$newOpml = new Opml();
$newOpml->parse(file_get_contents($_FILES['opml']['tmp_name']));
OpmlManager::save($newOpml, $opmlFile);
+
+ Cache::setStore($PlanetConfig->getCacheDir() . '/');
+ Cache::prune("html");
} elseif (isset($_POST['opml']) || isset($_POST['add'])) {
// Load old OPML
$oldOpml = OpmlManager::load($opmlFile);
@@ -79,6 +82,9 @@ if (isset($_POST['upload']) &&
// Save new OPML
OpmlManager::save($newOpml, $opmlFile);
+
+ Cache::setStore($PlanetConfig->getCacheDir() . '/');
+ Cache::prune("html");
}
header("Location: index.php");
die();