Option to force clear cache (#2052)

https://github.com/FreshRSS/FreshRSS/issues/1020#issuecomment-428515868
This commit is contained in:
Alexandre Alapetite
2018-10-17 18:03:50 +02:00
committed by GitHub
parent dfff5f2188
commit 0aecf44294
16 changed files with 34 additions and 1 deletions

View File

@@ -98,6 +98,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
$feed->_attributes('mark_updated_article_unread', Minz_Request::paramTernary('mark_updated_article_unread'));
$feed->_attributes('read_upon_reception', Minz_Request::paramTernary('read_upon_reception'));
$feed->_attributes('clear_cache', Minz_Request::paramTernary('clear_cache'));
if (FreshRSS_Auth::hasAccess('admin')) {
$feed->_attributes('ssl_verify', Minz_Request::paramTernary('ssl_verify'));

View File

@@ -286,6 +286,10 @@ class FreshRSS_Feed extends Minz_Model {
if (!$loadDetails) { //Only activates auto-discovery when adding a new feed
$feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
}
if ($this->attributes('clear_cache')) {
// Do not use `$simplePie->enable_cache(false);` as it would prevent caching in multiuser context
$this->clearCache();
}
Minz_ExtensionManager::callHook('simplepie_before_init', $feed, $this);
$mtime = $feed->init();
@@ -465,8 +469,16 @@ class FreshRSS_Feed extends Minz_Model {
$this->entries = $entries;
}
protected function cacheFilename() {
return CACHE_PATH . '/' . md5($this->url) . '.spc';
}
public function clearCache() {
return @unlink($this->cacheFilename());
}
public function cacheModifiedTime() {
return @filemtime(CACHE_PATH . '/' . md5($this->url) . '.spc');
return @filemtime($this->cacheFilename());
}
public function lock() {

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'Heslo',
'username' => 'Přihlašovací jméno',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'Stáhne zkrácenou verzi RSS kanálů (pozor, náročnější na čas!)',
'css_path' => 'Původní CSS soubor článku z webových stránek',
'description' => 'Popis',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP-Passwort',
'username' => 'HTTP-Nutzername',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'Ruft gekürzte RSS-Feeds ab (Achtung, benötigt mehr Zeit!)',
'css_path' => 'Pfad zur CSS-Datei des Artikels auf der Original-Webseite',
'description' => 'Beschreibung',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP password',
'username' => 'HTTP username',
),
'clear_cache' => 'Always clear cache',
'css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)',
'css_path' => 'Articles CSS path on original website',
'description' => 'Description',

View File

@@ -22,6 +22,7 @@ return array(
'password' => 'Contraseña HTTP',
'username' => 'Nombre de usuario HTTP',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'Recibir fuentes RSS truncadas (aviso, ¡necesita más tiempo!)',
'css_path' => 'Ruta a la CSS de los artículos en la web original',
'description' => 'Descripción',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'Mot de passe HTTP',
'username' => 'Identifiant HTTP',
),
'clear_cache' => 'Toujours vider le cache',
'css_help' => 'Permet de récupérer les flux tronqués (attention, demande plus de temps !)',
'css_path' => 'Sélecteur CSS des articles sur le site dorigine',
'description' => 'Description',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP סיסמה',
'username' => 'HTTP שם משתמש',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'קבלת הזנות RSS קטומות (זהירות, לוקח זמן רב יותר!)',
'css_path' => 'נתיב הCSS של המאמר באתר המקורי',
'description' => 'תיאור',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP password',
'username' => 'HTTP username',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'In caso di RSS feeds troncati (attenzione, richiede molto tempo!)',
'css_path' => 'Percorso del foglio di stile CSS del sito di origine',
'description' => 'Descrizione',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP 암호',
'username' => 'HTTP 사용자 이름',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => '글의 일부가 포함된 RSS 피드를 가져옵니다 (주의, 시간이 좀 더 걸립니다!)',
'css_path' => '웹사이트 상의 글 본문에 해당하는 CSS 경로',
'description' => '설명',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP wachtwoord',
'username' => 'HTTP gebruikers naam',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'Haalt verstoorde RSS feeds op (attentie, heeft meer tijd nodig!)',
'css_path' => 'Artikelen CSS pad op originele website',
'description' => 'Omschrijving',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'Senha HTTP',
'username' => 'Usuário HTTP',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'Retorna RSS feeds truncados (atenção, requer mais tempo!)',
'css_path' => 'Caminho do CSS do artigo no site original',
'description' => 'Descrição',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP password',// TODO
'username' => 'HTTP username',// TODO
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)',// TODO
'css_path' => 'Articles CSS path on original website',// TODO
'description' => 'Description',// TODO

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP şifre',
'username' => 'HTTP kullanıcı adı',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => 'Dikkat, daha çok zaman gerekir!',
'css_path' => 'Makaleleri kendi CSS görünümü ile göster',
'description' => 'Tanım',

View File

@@ -27,6 +27,7 @@ return array(
'password' => 'HTTP 密码',
'username' => 'HTTP 用户名',
),
'clear_cache' => 'Always clear cache', //TODO
'css_help' => '用于获取全文(注意,这将耗费更多时间!)',
'css_path' => '原文的 CSS 选择器',
'description' => '描述',

View File

@@ -205,6 +205,13 @@
</div>
</div>
<div class="form-group">
<label class="group-name" for="clear_cache"><?php echo _t('sub.feed.clear_cache'); ?></label>
<div class="group-controls">
<input type="checkbox" name="clear_cache" id="clear_cache" value="1"<?php echo $this->feed->attributes('clear_cache') ? ' checked="checked"' : ''; ?> />
</div>
</div>
<?php if (FreshRSS_Auth::hasAccess('admin')) { ?>
<div class="form-group">
<label class="group-name" for="timeout"><?php echo _t('sub.feed.timeout'); ?></label>