From 27ec67ad90ecd56ac3d05f6a9ea49b6faabf7d0a Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Mon, 6 Dec 2010 00:01:10 +0100 Subject: [PATCH] gitweb: Support legacy options used by kernel.org caching engine Try to translate between config variables used by gitweb caching patches[1] by John 'Warthog9' Hawley (J.H.) used, among others, by git.kernel.org, and new %cache_config options, but only if they were set in the config file. Note that $cache_enable is *not* translated to $caching_enabled. Footnotes: ~~~~~~~~~~ [1] See for example "Gitweb caching v7" thread on git mailing list: http://thread.gmane.org/gmane.comp.version-control.git/160147 Signed-off-by: Jakub Narebski --- gitweb/gitweb.perl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 89a394320a..294fbbbb18 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -284,6 +284,9 @@ our $caching_enabled = 0; # Suggested mechanism: # mv $cachedir $cachedir.flush && mkdir $cachedir && rm -rf $cachedir.flush our $cache; + +# Legacy options configuring behavior of git.kernel.org caching +our ($minCacheTime, $maxCacheTime, $cachedir, $backgroundCache, $maxCacheLife); # You define site-wide cache options defaults here; override them with # $GITWEB_CONFIG as necessary. our %cache_options = ( @@ -1363,6 +1366,19 @@ sub configure_caching { $cache ||= 'GitwebCache::FileCacheWithLocking'; eval "require $cache"; die $@ if $@; + + # support for legacy config variables configuring cache behavior + # (those variables are/were used by caching engine by John Hawley, + # used among others by custom gitweb at http://git.kernel.org); + # it assumes that if those variables are defined, then we should + # use them - no provision is made for having both legacy variables + # and new %cache_options set in config file(s). + $cache_options{'cache_root'} = $cachedir if defined $cachedir; + $cache_options{'expires_min'} = $minCacheTime if defined $minCacheTime; + $cache_options{'expires_max'} = $maxCacheTime if defined $maxCacheTime; + $cache_options{'background_cache'} = $backgroundCache if defined $backgroundCache; + $cache_options{'max_lifetime'} = $maxCacheLife if defined $maxCacheLife; + $cache = $cache->new({ %cache_options, #'cache_root' => '/tmp/cache', -- 2.11.4.GIT