diff options
author | Jan Lukas Gernert <jangernert@gmail.com> | 2020-03-14 15:59:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-14 15:59:10 +0300 |
commit | a70383c62e8603a5c4678a8c986ea3c587fda30a (patch) | |
tree | f645bcfc0cabfe3948076f5fc73efbb8972beb55 | |
parent | 4aed5c81f74f9145dac1305af9d12ba4e4790a39 (diff) | |
parent | b7f8a35ade023c4ca70fc60bdb39ab7fa7b04704 (diff) |
Merge pull request #983 from martijnvanbeers/feature/user_data_grabber
Check $XDG_USER_DATA for site grabber configs
-rw-r--r-- | src/ContentGrabber/grabber.vala | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/ContentGrabber/grabber.vala b/src/ContentGrabber/grabber.vala index 70d7bbfd..100fd74c 100644 --- a/src/ContentGrabber/grabber.vala +++ b/src/ContentGrabber/grabber.vala @@ -56,15 +56,28 @@ public class FeedReader.Grabber : GLib.Object { private bool checkConfigFile() { - string filepath = Constants.INSTALL_PREFIX + "/share/feedreader/GrabberConfig/"; + var filepaths = new Gee.ArrayList<string> (); + string userconf = GLib.Environment.get_user_data_dir() + "/feedreader/GrabberConfig/"; + if(FileUtils.test(userconf, GLib.FileTest.EXISTS)) + { + filepaths.add(userconf); + } + string globalconf = Constants.INSTALL_PREFIX + "/share/feedreader/GrabberConfig/"; + if(FileUtils.test(globalconf, GLib.FileTest.EXISTS)) + { + filepaths.add(globalconf); + } string hostName = grabberUtils.buildHostName(m_articleURL, false); - string filename = filepath + hostName + ".txt"; - if(FileUtils.test(filename, GLib.FileTest.EXISTS)) + foreach(string filepath in filepaths) { - m_config = new GrabberConfig(filename); - Logger.debug("Grabber: using config %s.txt".printf(hostName)); - return true; + string filename = filepath + hostName + ".txt"; + if(FileUtils.test(filename, GLib.FileTest.EXISTS)) + { + m_config = new GrabberConfig(filename); + Logger.debug("Grabber: using config %s.txt".printf(hostName)); + return true; + } } Logger.debug("Grabber: no config (%s.txt) found for article: %s".printf(hostName, m_articleURL)); @@ -72,16 +85,18 @@ public class FeedReader.Grabber : GLib.Object { string newHostName = grabberUtils.buildHostName(m_articleURL, true); if(hostName != newHostName) { - filename = filepath + newHostName + ".txt"; - if(FileUtils.test("%s%s.txt".printf(filename, newHostName), GLib.FileTest.EXISTS)) + foreach(string filepath in filepaths) { - m_config = new GrabberConfig(filename); - Logger.debug("Grabber: using config %s.txt".printf(newHostName)); - return true; + string filename = filepath + newHostName + ".txt"; + if(FileUtils.test("%s%s.txt".printf(filename, newHostName), GLib.FileTest.EXISTS)) + { + m_config = new GrabberConfig(filename); + Logger.debug("Grabber: using config %s.txt".printf(newHostName)); + return true; + } } } - Logger.debug("Grabber: no config (%s.txt) - cutSubdomain - found for article: %s".printf(newHostName, m_articleURL)); return false; } |