fixed a couple bugs and added size aware file cache

This commit is contained in:
JT Smith 2005-07-07 19:53:19 +00:00
parent cb2bf8dcaf
commit d72dd21826
9 changed files with 87 additions and 12 deletions

View file

@ -1,4 +1,5 @@
6.7.0
- Added asset versioning.
- fix [ 1229188 ] typo in Help: Collaboration, Post List Template Variables
- fix [ 1221284 ] Operation\user.pm i18n {internationalize labels}
- All form field labels have been internationalized.
@ -14,6 +15,7 @@
way to upload files will be through the File Pile. Anyone wishing to make
the File and Image assets available as normal assets in the new content
menu are still able to do so, and existing sites will be left as they are.
- Added a file cache size limit option to the config file.
6.6.3

View file

@ -7,6 +7,12 @@ upgrading from one version to the next, or even between multiple
versions. Be sure to heed the warnings contained herein as they will
save you many hours of grief.
6.7.0
--------------------------------------------------------------------
* The asset API has changed slightly due to versioning, so if you
have any custom assets, check out migration.txt to make
sure they will comply.
6.6.3
--------------------------------------------------------------------

View file

@ -432,6 +432,8 @@ $sth->finish;
print "\tConverting collateral manager items into assets\n" unless ($quiet);
WebGUI::SQL->write("update collateral set collateralFolderId='0' where collateralFolderId=''");
WebGUI::SQL->write("update collateral set collateralFolderId='0' where collateralFolderId is null");
my $collateralRootLineage = getNextLineage('PBasset000000000000002');
my $collateralRootId = WebGUI::SQL->setRow("asset","assetId",{
assetId=>"new",
@ -500,7 +502,7 @@ my $lastCollateralFolderId = 'nolastid';
my ($parentId, $baseLineage);
my $sth = WebGUI::SQL->read("select * from collateral order by collateralFolderId");
while (my $data = $sth->hashRef) {
next if ($data->{filename} eq "");
next if ($data->{filename} eq "" && $data->{collateralType} ne "snippet");
print "\t\tConverting collateral item ".$data->{collateralId}." for folder ".$data->{collateralFolderId}."\n" unless ($quiet);
unless ($lastCollateralFolderId eq $data->{collateralFolderId}) {
my $id = $data->{collateralFolderId};

View file

@ -21,12 +21,29 @@ GetOptions(
WebGUI::Session::open("../..",$configFile);
addAssetVersioning();
updateConfigFile();
insertHelpTemplate();
insertXSLTSheets();
insertSyndicatedContentTemplate();
WebGUI::Session::close();
sub updateConfigFile {
print "\tUpdating config file.\n" unless ($quiet);
my $pathToConfig = '../../etc/'.$configFile;
my $conf = Parse::PlainConfig->new('DELIM' => '=', 'FILE' => $pathToConfig, 'PURGE'=>1);
my %newConfig;
foreach my $key ($conf->directives) { # delete unwanted stuff
unless ($key eq "wobject") {
$newConfig{$key} = $conf->get($key);
}
}
$newConfig{fileCacheSizeLimit} = 100000000;
$conf->purge;
$conf->set(%newConfig);
$conf->write;
}
sub addAssetVersioning {
print "\tMaking changes for asset versioning\n" unless ($quiet);
WebGUI::SQL->write("create table assetVersionTag (

View file

@ -34,6 +34,10 @@ uploadsPath = /data/WebGUI/www/uploads
#fileCacheRoot=/path/to/cache
# Tell WebGUI how big to let the file cache grow in bytes.
fileCacheSizeLimit=100000000
# Support for the memcached distributed caching system.
# See http://www.danga.com/memcached/ for details on memcached.
# Uncomment this and point it to your memcached server(s). Use a

View file

@ -106,19 +106,20 @@ sub getIndexerParams {
sql => "select Article.assetId,
Article.linkTitle,
Article.linkURL,
asset.title,
asset.menuTitle,
asset.url,
assetData.title,
assetData.menuTitle,
assetData.url,
asset.className,
asset.ownerUserId,
asset.groupIdView,
asset.synopsis,
assetData.ownerUserId,
assetData.groupIdView,
assetData.synopsis,
wobject.description
from asset, Article
left join wobject on wobject.assetId = asset.assetId
left join assetData asset.assetId=assetData.assetId
where asset.assetId = Article.assetId
and asset.startDate < $now
and asset.endDate > $now",
and assetData.startDate < $now
and assetData.endDate > $now",
fieldsToIndex => ["linkTitle" ,"linkURL","title","menuTitle","url","synopsis","description" ],
contentType => 'content',
url => 'WebGUI::URL::gateway($data{url})',

View file

@ -66,7 +66,7 @@ These methods are available from this package:
sub _recurseCrumbTrail {
my ($sth, %data, $output);
tie %data, 'Tie::CPHash';
%data = WebGUI::SQL->quickHash("select assetId,parentId,menuTitle,url from asset where assetId=".quote($_[0]));
%data = WebGUI::SQL->quickHash("select asset.assetId,asset.parentId,assetData.menuTitle,asset.url from asset left join assetData on asset.assetId=assetData.assetId where asset.assetId=".quote($_[0])." group by assetData.assetId order by assetData.revisionDate desc");
if ($data{assetId}) {
$output .= _recurseCrumbTrail($data{parentId});
}

View file

@ -14,7 +14,7 @@ package WebGUI::Cache::FileCache;
=cut
use Cache::FileCache;
use Cache::SizeAwareFileCache;
use HTTP::Headers;
use HTTP::Request;
@ -136,7 +136,7 @@ sub new {
auto_purge_on_set=>1
);
$options{cache_root} = $session{config}{fileCacheRoot} if ($session{config}{fileCacheRoot});
$cache = new Cache::FileCache(\%options);
$cache = new Cache::SizeAwareFileCache(\%options);
bless {_cache => $cache, _key => $key}, $class;
}
@ -197,6 +197,25 @@ sub setByHTTP {
return $response->content;
}
#-------------------------------------------------------------------
=head2 shrink ( [ size ] )
Reduces the cache down to a specific size to conserve filesystem space.
=head3 size
A size to shrink the cache to in bytes. Defaults to the fileCacheSizeLimit variable in the config file.
=cut
sub shrink {
my $self = shift;
my $size = shift || $session{config}{fileCacheSizeLimit} || 10000000;
$self->{_cache}->limit_size($size);
}
#-------------------------------------------------------------------
=head2 stats ( )

View file

@ -0,0 +1,24 @@
package Hourly::CleanFileCache;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Session;
use WebGUI::Cache::FileCache;
#-------------------------------------------------------------------
sub process {
my $cache = WebGUI::Cache::FileCache->new;
$cache->shrink;
}
1;