]> git.wh0rd.org - tt-rss.git/commitdiff
implement SIMPLEPIE_CACHE_DIR
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 25 Aug 2007 16:24:18 +0000 (17:24 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 25 Aug 2007 16:24:18 +0000 (17:24 +0100)
config.php-dist
functions.php
update_daemon.php

index 0cd257beddac488ccdeb365ec0cd562364f966ae..a011b0d66d975939c8c209019f6c1f395fc4e1a8 100644 (file)
        // to any feeds using HTTP Digest authentication and Magpie XML parsing 
        // errors are bothering you too much, you can try enabling SimplePie.
 
+       define('SIMPLEPIE_CACHE_DIR',   '/var/tmp/simplepie-ttrss-cache');
+       // Cache directory for RSS feeds when using SimplePie
+
        define('COUNTERS_MAX_AGE', 365);
        // Hard limit for unread counters calculation. Try tweaking this
        // parameter to speed up tt-rss when having a huge number of articles
index 2aac7f3dbba414793bfa6ea5d537310ca4a6a819..8cb2b5447897d386fb193f634df2ce4300e97b2c 100644 (file)
                        (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
        }
 
+       function get_feed_update_interval($link, $feed_id) {
+               $result = db_query($link, "SELECT owner_uid, update_interval FROM
+                       ttrss_feeds WHERE id = '$feed_id'");
+
+               if (db_num_rows($result) == 1) {
+                       $update_interval = db_fetch_result($result, 0, "update_interval");
+                       $owner_uid = db_fetch_result($result, 0, "owner_uid");
+
+                       if ($update_interval != 0) {
+                               return $update_interval;
+                       } else {
+                               return get_pref($link, 'DEFAULT_UPDATE_INTERVAL', $owner_uid, false);
+                       }
+
+               } else {
+                       return -1;
+               }
+       }
+
        function update_all_feeds($link, $fetch, $user_id = false, $force_daemon = false) {
 
                if (WEB_DEMO_MODE) return;
                if (!ENABLE_SIMPLEPIE) {
                        $rss = fetch_rss($fetch_url);
                } else {
+                       if (!is_dir(SIMPLEPIE_CACHE_DIR)) {
+                               mkdir(SIMPLEPIE_CACHE_DIR);
+                       }
+
                        $rss = new SimplePie();
                        $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT);
                        $rss->set_timeout(MAGPIE_FETCH_TIME_OUT);
                        $rss->set_feed_url($fetch_url);
                        $rss->set_output_encoding('UTF-8');
+
+                       if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
+                               _debug("feed update interval (sec): " .
+                                       get_feed_update_interval($link, $feed)*60);
+                       }
+
+                       if (is_dir(SIMPLEPIE_CACHE_DIR)) {
+                               $rss->set_cache_location(SIMPLEPIE_CACHE_DIR);
+                               $rss->set_cache_duration(get_feed_update_interval($link, $feed) * 60);
+                       }
+
                        $rss->init();
                }
 
index ce5d2535efec456ea34c49711870ab9d9be92bb7..50d13191cff6c1d33b7b74dd39bae3c69f5a6975 100644 (file)
@@ -9,6 +9,7 @@
        declare(ticks = 1);
 
        define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache-daemon');
+       define('SIMPLEPIE_CACHE_DIR',   '/var/tmp/simplepie-ttrss-cache-daemon');
        define('DISABLE_SESSIONS', true);
 
        require_once "version.php";